From db0b3003b013c824dc15b97c9ae037f6067b4d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Thu, 1 Feb 2024 12:47:22 +0100 Subject: [PATCH] feat: modularize package --- .github/workflows/npm-publish.yml | 22 ++++++++++++++++++++++ index.js | 6 ++++++ package.json | 13 +++++++++++-- truffle-config.js | 9 ++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/npm-publish.yml create mode 100644 index.js diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..12cb97dc8 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,22 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Publish NPM package + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + - run: yarn install + - run: yarn publish + env: + NODE_AUTH_TOKEN: ${{SECRETS.NPM_TOKEN}} \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 000000000..ee1c80d51 --- /dev/null +++ b/index.js @@ -0,0 +1,6 @@ +const addresses = require("./migrations/witnet.addresses.json") +const settings = require("./migrations/witnet.settings") +module.exports = { + addresses, + settings +} \ No newline at end of file diff --git a/package.json b/package.json index 794351cb0..4a977900d 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,22 @@ "version": "2.0.1", "description": "Witnet Solidity Bridge contracts for EVM-compatible chains", "main": "", + "type": "commonjs", + "export": { + ".": "./index.js" + }, + "files": [ + "build", + "contracts", + "migrations/witnet.*" + ], "scripts": { "addresses": "node ./scripts/addresses.js 2>&1", "clean": "npm run clean:build && npm run clean:flattened", "clean:build": "node ./scripts/clean.js build", "clean:flattened": "node ./scripts/clean.js flattened", - "compile": "truffle compile --all --network", - "console": "truffle console", + "compile": "npx truffle compile --all --network", + "console": "npx truffle console", "coverage": "solidity-coverage", "flatten": "node ./scripts/flatten.js 2>&1", "flatten:all": "npm run clean && npm run flatten:core && npm run flatten:apps && npm run flatten:libs && npm run flatten:proxy", diff --git a/truffle-config.js b/truffle-config.js index b97a944c2..81283e961 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -13,11 +13,14 @@ if (!settings.networks[realm] || !settings.networks[realm][network]) { process.exit(1) } } -console.info(` + +if (realm !== "default") console.info(` Targetting "${realm.toUpperCase()}" realm -===================${"=".repeat(realm.length)}`) +===================${"=".repeat(realm.length)} +`); + module.exports = { - build_directory: `./build/${realm}/`, + build_directory: `./build/`, contracts_directory: "./contracts/", migrations_directory: "./migrations/scripts/", networks: settings.networks[realm],