From d9870c82fff04d05b59960750bb7748119066af0 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Tue, 27 Jun 2023 10:56:23 -0700 Subject: [PATCH] Follow 1155 contracts way to publish with source code --- .gitignore | 1 + foundry.toml | 2 +- js-scripts/bundle-chainConfigs.mjs | 7 +------ package.json | 11 ++++++----- tsconfig.json | 9 ++++----- tsup.config.ts | 10 ++++++++++ yarn.lock | 18 ++++++++++++++++++ 7 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 tsup.config.ts diff --git a/.gitignore b/.gitignore index 1cca58d..f3e70ce 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ cache .pkey .env.* dist/ +out/ .idea broadcast/ \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index b1e7bec..8f14bb6 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,7 +3,7 @@ solc_version = '0.8.17' optimizer = true optimizer_runs = 3000 via_ir = true -out = 'dist/artifacts' +out = 'out' test = 'test' src = 'src' libs = ['lib'] diff --git a/js-scripts/bundle-chainConfigs.mjs b/js-scripts/bundle-chainConfigs.mjs index ec6567c..0f0b4f3 100644 --- a/js-scripts/bundle-chainConfigs.mjs +++ b/js-scripts/bundle-chainConfigs.mjs @@ -1,12 +1,7 @@ import { readdirSync, readFileSync, writeFileSync } from 'fs'; // Reads all the chain configs in ./chainConfigs folder, and bundles them into a typescript -// definition that looks like: -// export const chainConfigs = { -// [chainId]: { -// ...chainConfig -// } -//} +// definition function makeConfig() { // read all files in the chainConfigs folder const files = readdirSync('chainConfigs'); diff --git a/package.json b/package.json index 345b461..62c4bd9 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,11 @@ "private": false, "type": "module", "files": [ - "dist/chainConfigs/*", - "dist/addresses/*", - "dist/index*" + "dist/", + "src/", + "addresses/", + "chainConfigs/", + "package/" ], "main": "./dist/index.cjs", "types": "./dist/index.d.ts", @@ -17,7 +19,7 @@ "test": "forge test", "generate-merkle-test-file": "node scripts/merkle-test.mjs", "clean": "rm -rf ./dist/", - "prepack": "node js-scripts/copy-latest-deployment-addresses.mjs && yarn run wagmi && yarn build-ts && yarn copy-addresses-and-configs", + "prepack": "yarn clean && node js-scripts/copy-latest-deployment-addresses.mjs && yarn wagmi && yarn bundle-configs && yarn build-ts", "deploy": "node scripts/deploy.mjs", "coverage": "forge coverage --report lcov", "build": "forge build", @@ -25,7 +27,6 @@ "bundle-configs": "node js-scripts/bundle-chainConfigs.mjs && yarn format", "prettier": "npx prettier \"js-scripts/**/*.mjs\" \"package/**/*.ts\" \"wagmi.config.ts\" --check", "prettier:fix": "npm run prettier -- --write", - "copy-addresses-and-configs": "cp -r addresses/ dist/addresses && cp -r chainConfigs/ dist/chainConfigs", "wagmi": "wagmi generate", "storage-inspect:check": "./script/storage-check.sh check ERC721Drop ERC721DropProxy FactoryUpgradeGate ZoraNFTCreatorProxy ZoraNFTCreatorV1", "storage-inspect:generate": "./script/storage-check.sh generate ERC721Drop ERC721DropProxy FactoryUpgradeGate ZoraNFTCreatorProxy ZoraNFTCreatorV1" diff --git a/tsconfig.json b/tsconfig.json index 804ca73..ed93685 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ "lib": ["es2021"], "module": "esnext", "moduleResolution": "node", - "noEmit": true, "noImplicitAny": true, "noUncheckedIndexedAccess": true, "noUnusedLocals": true, @@ -18,11 +17,11 @@ "strict": true, "strictNullChecks": true, "target": "es2021", - "types": ["node"] + "types": ["node"], + "outDir": "dist" }, "exclude": ["node_modules/**", "dist/**"], "include": [ - "package/**/*.ts", - "js-scripts/**/*.mjs" - ] + "package/**/*.ts" + ], } \ No newline at end of file diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..3be140a --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + entry: ['package/index.ts'], + sourcemap: true, + clean: true, + dts: false, + format: ['cjs'], + onSuccess: 'tsc --emitDeclarationOnly --declaration --declarationMap' +}) \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c7acf28..cee01c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1385,6 +1385,17 @@ glob@7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^10.2.5: + version "10.3.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.0.tgz#763d02a894f3cdfc521b10bbbbc8e0309e750cce" + integrity sha512-AQ1/SB9HH0yCx1jXAT4vmCbTOPe5RQ+kCurjbel5xSCGhebumUv+GJZfa1rEqor3XIViqwSEmlkZCQD43RWrBg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.0.3" + minimatch "^9.0.1" + minipass "^5.0.0 || ^6.0.2" + path-scurry "^1.7.0" + glob@^10.2.7: version "10.2.7" resolved "https://registry.yarnpkg.com/glob/-/glob-10.2.7.tgz#9dd2828cd5bc7bd861e7738d91e7113dda41d7d8" @@ -2156,6 +2167,13 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== +rimraf@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.1.tgz#0881323ab94ad45fec7c0221f27ea1a142f3f0d0" + integrity sha512-OfFZdwtd3lZ+XZzYP/6gTACubwFcHdLRqS9UX3UwpU2dnGQYkPFISRwvM3w9IiB2w7bW5qGo/uAwE4SmXXSKvg== + dependencies: + glob "^10.2.5" + rollup@^3.2.5: version "3.21.6" resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.21.6.tgz#f5649ccdf8fcc7729254faa457cbea9547eb86db"