Skip to content

Commit

Permalink
renaming build directory method to more generic name + styling (#278)
Browse files Browse the repository at this point in the history
* renaming build directory method to more generic name + styling

* typo

* replacing all instances of '_discoveryprovider-test-init.js' to '_contractsLocalSetup.js' and adding path.join()'s
  • Loading branch information
vicky-g committed Feb 4, 2020
1 parent 121b537 commit ed20eb2
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion content-service/scripts/migrate_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if [ -d "../contracts/build/contracts" ]
then
echo "Audius contracts repo is present"
cd ../contracts/
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run-audlib
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run-audlib
else
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getDirectoryRoot = (dirName) => {
/** Print expected usage */
const printUsageAndThrow = () => {
console.log('\nIncorrect usage. Please use the following format:')
console.log('truffle exec _discoveryprovider-test-init.js -run')
console.log('truffle exec _contractsLocalSetup.js -run')
console.log('')
throw new Error('Incorrect usage')
}
Expand All @@ -54,7 +54,7 @@ const copyBuildDirectory = async (outputPath) => {
let dir = path.join(__dirname, '..')
let localTarget = path.join(dir, 'build/contracts')

await createContractsDir(outputPath)
await createDir(outputPath)

// clean up unnecessary metadata and copy ABI
let files = fs.readdirSync(localTarget)
Expand All @@ -69,12 +69,12 @@ const copyBuildDirectory = async (outputPath) => {
})
}

/** Creates build/contracts folder if folder is not present */
async function createContractsDir (dir) {
/** Creates directory if path does not exist */
async function createDir (dir) {
try {
await fs.ensureDir(dir)
} catch (err) {
console.log(`Error with creating build/contracts folder: ${err}`)
console.log(`Error with creating folder at path ${dir}: ${err}`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/scripts/circle-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function main {
echo 'Migrating contracts'
node_modules/.bin/truffle migrate
echo 'Writing flask config'
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run
cd_discprov_repo
pytest -s -v --fulltrace
}
Expand Down
4 changes: 2 additions & 2 deletions discovery-provider/scripts/sample-setup-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Saving successful migration to network...
Saving artifacts...
+ echo '\nWriting flask config file'
\nWriting flask config file
+ truffle exec scripts/_discoveryprovider-test-init.js -run
+ truffle exec scripts/_contractsLocalSetup.js -run
Using network 'development'.

/Users/hareeshnagaraj/Development/audius-discovery-provider/contract_config.ini
Expand All @@ -98,7 +98,7 @@ Perform some random operations on deployed Audius contracts? (y/n)y+ echo
+ [[ y =~ ^[Yy]$ ]]
+ echo '\nAdding 4 random creators'
\nAdding 4 random creators
+ truffle exec scripts/_discoveryprovider-test-init.js -test
+ truffle exec scripts/_contractsLocalSetup.js -test
Using network 'development'.

{ tx:
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function main {
node_modules/.bin/truffle migrate

echo '\nWriting flask config file'
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run
fi

cd_discprov_repo
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ npm run ganache
sleep 5

node_modules/.bin/truffle migrate
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run
cd_discprov_repo

# Stop dependencies, if present
Expand Down
38 changes: 17 additions & 21 deletions eth-contracts/scripts/migrate-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const copyBuildDirectory = async (outputDirPath) => {
const dir = path.join(__dirname, '..')
const localTarget = path.join(dir, 'build/contracts')

await createEthContractsDir(outputDirPath)
await createDir(outputDirPath)

// clean up unnecessary metadata and copy ABI
const files = fs.readdirSync(localTarget)
Expand All @@ -51,12 +51,12 @@ const copyBuildDirectory = async (outputDirPath) => {
})
}

/** Creates libs/eth-contracts folder if folder is not present */
async function createEthContractsDir (dir) {
/** Creates directory if path does not exist */
async function createDir (dir) {
try {
await fs.ensureDir(dir)
} catch (err) {
console.log(`Error with creating libs/eth-contracts folder: ${err}`)
console.log(`Error with creating folder at path ${dir}: ${err}`)
}
}

Expand All @@ -65,7 +65,7 @@ async function createEthContractsDir (dir) {
* config file contains deployed AudiusToken and Registry contract addresses, and ownerWallet
*/
const outputJsonConfigFile = async (outputFilePath) => {
try{
try {
const audiusToken = await AudiusToken.deployed()
const registry = await Registry.deployed()
let outputDictionary = {}
Expand All @@ -75,13 +75,12 @@ const outputJsonConfigFile = async (outputFilePath) => {
outputDictionary['allWallets'] = await web3.eth.getAccounts()

fs.writeFile(outputFilePath, JSON.stringify(outputDictionary), (err) => {
if(err != null){
if (err != null) {
console.log(err)
}
})
console.log(outputDictionary)
}
catch (e) {
} catch (e) {
console.log(e)
}
}
Expand All @@ -96,31 +95,28 @@ module.exports = async callback => {

// output to Identity Service
try {
outputJsonConfigFile(getDirectoryRoot(AudiusIdentityService) + '/eth-contract-config.json')
}
catch (e) {
outputJsonConfigFile(path.join(getDirectoryRoot(AudiusIdentityService), '/eth-contract-config.json'))
} catch (e) {
console.log("Identity service doesn't exist, probably running via E2E setup scripts", e)
}

// output to Creator Node
try {
outputJsonConfigFile(getDirectoryRoot(AudiusCreatorNode) + '/eth-contract-config.json')
}
catch (e) {
outputJsonConfigFile(path.join(getDirectoryRoot(AudiusCreatorNode), '/eth-contract-config.json'))
} catch (e) {
console.log("Creator node doesn't exist, probably running via E2E setup scripts", e)
}

// special case for content service which isn't run locally for E2E test or during front end dev
try {
outputJsonConfigFile(getDirectoryRoot(AudiusContentService) + '/eth-contract-config.json')
}
catch (e) {
outputJsonConfigFile(path.join(getDirectoryRoot(AudiusContentService), '/eth-contract-config.json'))
} catch (e) {
console.log("Content service folder doesn't exist, probably running via E2E setup scripts", e)
}
const dappOutput = os.homedir() + '/.audius'

const dappOutput = path.join(os.homedir(), './audius')
if (!fs.existsSync(dappOutput)) {
fs.mkdirSync(dappOutput, { recursive: true })
}
outputJsonConfigFile(dappOutput + '/eth-config.json')
outputJsonConfigFile(path.join(dappOutput, '/eth-config.json'))
}
4 changes: 2 additions & 2 deletions libs/scripts/migrate_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ if [ -d "../contracts/build/contracts" ]
then
echo "Audius contracts repo is present"
cd ../contracts/
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run-audlib
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run-audlib

echo "Writing flask config file"
node_modules/.bin/truffle exec scripts/_discoveryprovider-test-init.js -run
node_modules/.bin/truffle exec scripts/_contractsLocalSetup.js -run
else
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
exit 1
Expand Down

0 comments on commit ed20eb2

Please sign in to comment.