Skip to content

Commit

Permalink
docs(examples/supply-chain): fix yarn --no-lockfile
Browse files Browse the repository at this point in the history
Primary Changes
---------------
1. Removed examples/supply-chain-app/package.json and
   moved the other files to cactus-example-supply
   -chain-backend
2. Updated the docs to match the updated path of the
   supply-chain-app files to cactus-example-supply-
   chain-backend and the new steps on how run the
   latest supply chain app
3. Updated the code responses in connector-fabric from
   null to (0) based on the logs and responses while
   running the application.
4. Added a parse.int for shelfCount in bookshelf-
   converter because it requires a number but instead
   the value becomes a string before it is submitted.

Fixes #2721

Signed-off-by: aldousalvarez <aldousss.alvarez@gmail.com>
  • Loading branch information
aldousalvarez committed Jan 25, 2024
1 parent a33f30c commit 53a0a15
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ jobs:
steps:
- uses: actions/checkout@v3.5.2
- name: ghcr.io/hyperledger/cactus-example-supply-chain-app
run: DOCKER_BUILDKIT=1 docker build . -f ./examples/supply-chain-app/Dockerfile -t cactus-example-supply-chain-app
run: DOCKER_BUILDKIT=1 docker build . -f ./examples/cactus-example-supply-chain-backend/Dockerfile -t cactus-example-supply-chain-app
- name: Run Trivy vulnerability scan for cactus-example-supply-chain-app
uses: aquasecurity/trivy-action@0.11.2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-supply-chain-app-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-20.04
env:
DOCKER_BUILDKIT: 1
DOCKERFILE_PATH: ./examples/supply-chain-app/Dockerfile
DOCKERFILE_PATH: ./examples/cactus-example-supply-chain-backend/Dockerfile
DOCKER_BUILD_DIR: ./
permissions:
packages: write
Expand Down
2 changes: 1 addition & 1 deletion .vscode/template.launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
],
"console": "integratedTerminal",
"sourceMaps": true,
"cwd": "${workspaceFolder}/examples/supply-chain-app/",
"cwd": "${workspaceFolder}/examples/cactus-example-supply-chain-backend/",
"outFiles": [
"${workspaceFolder}/**/*.js",
"!**/node_modules/**"
Expand Down
2 changes: 1 addition & 1 deletion docs-cactus/source/examples/supply-chain-app.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
```{include} ../../../examples/supply-chain-app/README.md
```{include} ../../../examples/cactus-example-supply-chain-backend/README.md
:relative-images:
```
84 changes: 42 additions & 42 deletions docs/docs/cactus/examples/supply-chain-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Usage
--------------------------------------------

1. Execute the following from:

docker run \\
\--rm \\
\--privileged \\
Expand All @@ -16,25 +16,25 @@ Usage
\-p 4100:4100 \\
\-p 4200:4200 \\
ghcr.io/hyperledger/cactus-example-supply-chain-app:2022-04-05--feat-1579

2. Observe the example application pulling up in the logs

1. the test ledger containers,

2. a test consortium with multiple members and their Cactus nodes

3. Wait for the output to show the message `INFO (api-server): Cactus Cockpit reachable http://0.0.0.0:3200`

4. Visit http://0.0.0.0:3200 in your web browser with Javascript enabled


Building and running the container locally
----------------------------------------------------------------------------------------------------------------------

\# Change directories to the project root

\# Build the docker image and tag it as "scaeb" for supply chain app example backend
DOCKER\_BUILDKIT\=1 docker build \-f ./examples/supply-chain-app/Dockerfile . \-t scaeb
DOCKER\_BUILDKIT\=1 docker build \-f ./examples/cactus-example-supply-chain-backend/Dockerfile . \-t scaeb

\# Run the built image with ports mapped to the host machine as you see fit
\# The --privileged flag is required because we use Docker-in-Docker for pulling
Expand All @@ -47,7 +47,7 @@ Building the image with a specific npm package version:

DOCKER\_BUILDKIT\=1 docker build \\
\--build-arg NPM\_PKG\_VERSION\=jwt-supply-chain \\
\--file ./examples/supply-chain-app/Dockerfile \\
\--file ./examples/cactus-example-supply-chain-backend/Dockerfile \\
\--tag scaeb \\
./

Expand All @@ -58,70 +58,70 @@ Running the Example Application Locally
On the terminal, issue the following commands:

1. `npm run install-yarn`
2. `yarn configure`
1. `npm run enable-corepack`

2. `yarn run configure`

3. `yarn start:example-supply-chain`


Debugging the Example Application Locally
--------------------------------------------------------------------------------------------------------------------

On the terminal, issue the following commands (steps 1 to 6) and then perform the rest of the steps manually.

1. `npm run install-yarn`
1. `npm run enable-corepack`

2. `yarn configure`

3. `yarn build:dev`
4. `cd ./examples/supply-chain-app/`
5. `yarn --no-lockfile`

4. `cd ./examples/cactus-example-supply-chain-backend/`

5. `yarn install`

6. `cd ../../`

7. Locate the `.vscode/template.launch.json` file

8. Within that file locate the entry named `"Example: Supply Chain App"`

9. Copy the VSCode debug definition object from 2) to your `.vscode/launch.json` file

10. At this point the VSCode `Run and Debug` panel on the left should have an option also titled `"Example: Supply Chain App"` which starts the application

11. When the application finishes loading, the JWT token generated is displayed on the terminal

12. Visit http://localhost:3200 in a web browser with Javascript enabled and insert the token when prompted


Live Reloading the GUI Application
------------------------------------------------------------------------------------------------------

1. `npm run install-yarn`
1. `npm run enable-corepack`

2. `yarn configure`

3. `yarn build:dev`

4. Locate the `.vscode/template.launch.json` file

5. Within that file locate the entry named `"Example: Supply Chain App"`

6. Copy the VSCode debug definition object from 2) to your `.vscode/launch.json` file

7. At this point the VSCode `Run and Debug` panel on the left should have an option also titled `"Example: Supply Chain App"` which starts the application

8. `cd ./examples/cactus-example-supply-chain-frontend/`

9. `yarn serve:proxy`

10. When the application finishes loading, the JWT token generated is displayed on the terminal

11. Visit http://localhost:8000 in a web browser with Javascript enabled and insert the token when prompted

12. At this point if you modify the source code of the GUI application under the `./examples/cactus-example-supply-chain-frontend/` path it will automatically reload the browser window (you will need to paste in the JWT again when this happens)


[Previous](../examples.md "Examples") [Next](../governance.md "Governance")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ coverage/
# Introperability App specifics
examples/simple-asset-transfer/fabric/**/hfc-key-store/

examples/supply-chain-app/Dockerfile
examples/cactus-example-supply-chain-backend/Dockerfile

bin/
.tmp/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN source ~/.bashrc && \
SHELL ["/bin/bash", "--login", "-c"]


COPY --chown=${APP_USER}:${APP_USER} ./examples/supply-chain-app/healthcheck.sh /
COPY --chown=${APP_USER}:${APP_USER} ./examples/cactus-example-supply-chain-backend/healthcheck.sh /

ENV AUTHORIZATION_CONFIG_JSON="{}"
ENV AUTHORIZATION_PROTOCOL=NONE
Expand All @@ -67,7 +67,7 @@ ENV API_PORT=4000
ENV GRPC_TLS_ENABLED=false
ENV LOG_LEVEL=TRACE

COPY examples/supply-chain-app/supervisord.conf /etc/supervisord.conf
COPY examples/cactus-example-supply-chain-backend/supervisord.conf /etc/supervisord.conf

# supervisord web ui/dashboard
EXPOSE 9001
Expand All @@ -91,4 +91,4 @@ USER root
ENTRYPOINT ["/usr/bin/supervisord"]
CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"]
HEALTHCHECK --interval=1s --timeout=5s --start-period=20s --retries=250 \
CMD /usr/src/app/examples/supply-chain-app/healthcheck.sh
CMD /usr/src/app/examples/cactus-example-supply-chain-backend/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Change directories to the project root
# Build the docker image and tag it as "scaeb" for supply chain app example backend
DOCKER_BUILDKIT=1 docker build -f ./examples/supply-chain-app/Dockerfile . -t scaeb
DOCKER_BUILDKIT=1 docker build -f ./examples/cactus-example-supply-chain-backend/Dockerfile . -t scaeb
# Run the built image with ports mapped to the host machine as you see fit
# The --privileged flag is required because we use Docker-in-Docker for pulling
Expand All @@ -43,7 +43,7 @@ Building the image with a specific npm package version:
```sh
DOCKER_BUILDKIT=1 docker build \
--build-arg NPM_PKG_VERSION=jwt-supply-chain \
--file ./examples/supply-chain-app/Dockerfile \
--file ./examples/cactus-example-supply-chain-backend/Dockerfile \
--tag scaeb \
./
```
Expand All @@ -63,10 +63,10 @@ On the terminal, issue the following commands:
On the terminal, issue the following commands (steps 1 to 6) and then perform the rest of the steps manually.

1. `npm run enable-corepack`
2. `npm run configure`
2. `yarn run configure`
3. `yarn build:dev`
4. `cd ./examples/supply-chain-app/`
5. `yarn --no-lockfile`
4. `cd ./examples/cactus-example-supply-chain-backend/`
5. `yarn install`
6. `cd ../../`
7. Locate the `.vscode/template.launch.json` file
8. Within that file locate the entry named `"Example: Supply Chain App"`
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/cactus-example-supply-chain-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"dist/*"
],
"scripts": {
"start": "node -r dotenv/config dist/lib/main/typescript/supply-chain-app-cli.js dotenv_config_path=process.env",
"start-direct": "node ./node_modules/@hyperledger/cactus-example-supply-chain-backend/dist/lib/main/typescript/supply-chain-app-cli.js",
"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev",
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.7.0;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import { SupplyChainAppDataModelLib as model } from "./SupplyChainAppDataModel.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.7.0;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import { SupplyChainAppDataModelLib as model } from "./SupplyChainAppDataModel.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stderr_logfile=/usr/src/app/log/dockerd.err.log
stdout_logfile=/usr/src/app/log/dockerd.out.log

[program:supply-chain-app]
command=/home/appuser/.nvm/versions/node/v16.8.0/bin/node /usr/src/app/node_modules/@hyperledger/cactus-example-supply-chain-backend/dist/lib/main/typescript/supply-chain-app-cli.js
command=/home/appuser/.nvm/versions/node/v16.14.2/bin/node /usr/src/app/node_modules/@hyperledger/cactus-example-supply-chain-backend/dist/lib/main/typescript/supply-chain-app-cli.js
autostart=true
autorestart=unexpected
startretries=20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export class BookshelfConverter {
const errMsg = `Expected the value of arr[${BookshelfConverter.SOLIDITY_FIELD_ID}] to be a string`;
throw new RuntimeError(errMsg);
}
const shelfCount = arr[BookshelfConverter.SOLIDITY_FIELD_SHELF_COUNT];
const shelfCountStr = arr[
BookshelfConverter.SOLIDITY_FIELD_SHELF_COUNT
] as string;
const shelfCount = parseInt(shelfCountStr, 10);
if (typeof shelfCount !== "number") {
const errMsg = `Expected the value of arr[${BookshelfConverter.SOLIDITY_FIELD_SHELF_COUNT}] to be a number`;
throw new RuntimeError(errMsg);
Expand Down
8 changes: 4 additions & 4 deletions examples/cactus-example-supply-chain-frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
"browserTarget": "app:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"ci": {

}
}
},
Expand Down Expand Up @@ -176,9 +178,7 @@
}
},
"cli": {
"schematicCollections": [
"@ionic/angular-toolkit"
],
"schematicCollections": ["@ionic/angular-toolkit"],
"analytics": false
},
"schematics": {
Expand Down
55 changes: 0 additions & 55 deletions examples/supply-chain-app/package.json

This file was deleted.

Loading

0 comments on commit 53a0a15

Please sign in to comment.