1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/scripts/createCodeExamples.sh
Bogdan Fazakas a026c12041
Compute Example Readme flow (#1615)
* wip

* add logs

* update checksum

* update test suite

* temp run just compute flow tests

* update file urle

* add c2d md file

* renamed files

* update script

* add script logs

* update create example script

* Updating CodeExamples.md

* Updating ComputeExamples.md

* readme text improvments

* Updating ComputeExamples.md

* more improvments

* Updating ComputeExamples.md

* again more improvments

* Updating ComputeExamples.md

* more readme improvments

* Updating ComputeExamples.md

* update chainid and service endpoint

* Updating CodeExamples.md

* Updating ComputeExamples.md

* req fixes

* Updating ComputeExamples.md

* more fixes

* Updating CodeExamples.md

* Updating ComputeExamples.md

* more fixes, ts configs etc

* Updating ComputeExamples.md

* mention typescript compile options

* add comment regarding mint method

* fix lint

* Updating ComputeExamples.md

* review fixes and sugestions

* Updating ComputeExamples.md

Co-authored-by: GitHub Actions Bot <>
2022-12-14 17:22:44 +02:00

49 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# We get the path to the test script that we want to use as a template
inputfile=$1
# We check if the input file exists
if [ ! -f "$inputfile" ]; then
echo "File $inputfile does not exist"
exit 1
fi
echo "File $inputfile found"
inputesize=$(md5sum $inputfile)
echo $inputesize
# We get the path to the output file
outputfile="$(basename -a -s .test.ts $inputfile).md"
echo "Generated output $outputfile "
# Create markdown file
cp $inputfile $outputfile
echo "after copy into $outputfile"
# Parameters of sed command depending on the OS
if [[ $(uname) == 'Darwin' ]]; then
# if platform is Mac OS X
params="-i '' -e "
else
params="-i "
fi
# Remove unneccessay imports
eval "sed $params \"s/import { assert } from 'chai'//\" $outputfile"
# Change imports
eval "sed $params \"s/} from '..\/..\/src'/} from '@oceanprotocol\/lib'/\" $outputfile"
# Replace comments
eval "sed $params \"s/}) \/\/\/ //\" $outputfile"
eval "sed $params \"s/}) \/\/\///\" $outputfile"
eval "sed $params \"s/ \/\/\/ //\" $outputfile"
eval "sed $params \"s/ \/\/\/ //\" $outputfile"
eval "sed $params \"s/\/\/\/ //\" $outputfile"
# Generate titles
eval "sed $params \"s/describe('Simple Publish & Consume Flow', async () => {//\" $outputfile"
eval "sed $params \"s/it('/\#\#\# /\" $outputfile"
eval "sed $params \"s/', async () => {//\" $outputfile"
eval "sed $params \"s/before(async () => {//\" $outputfile"