Skip to content

Commit 08ae214

Browse files
authored
Merge pull request #596 from stephensli/fix/package-flatten
fix: use npm run publish to release the dist folder directly
2 parents f0c8b02 + 30a75e4 commit 08ae214

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

build/pack-publish-block.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This is meant to run in a hook before npm pack.
2+
// Reporting an error from the hook interrupts the command.
3+
if (process.env.BYPASS_SAFETY_CHECK === 'false' || process.env.BYPASS_SAFETY_CHECK === undefined) {
4+
console.error('Run `npm run build:tarball` or `npm run publish:tarball` to pack or publish the package');
5+
process.exit(1);
6+
} else if (process.env.BYPASS_SAFETY_CHECK !== 'true') {
7+
console.error('Invalid value of the BYPASS_SAFETY_CHECK variable. Must be "true", "false" or unset.');
8+
process.exit(1);
9+
}

package.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
"name": "solc",
33
"version": "0.8.11",
44
"description": "Solidity compiler",
5-
"main": "dist/index.js",
5+
"main": "index.js",
66
"bin": {
7-
"solcjs": "dist/solc.js"
7+
"solcjs": "solc.js"
88
},
99
"scripts": {
1010
"build": "tsc",
1111
"postbuild": "node build/postbuild.js",
1212
"lint": "eslint --ext .js,.ts .",
1313
"lint:fix": "eslint --fix --ext .js,.ts .",
1414
"updateBinary": "node build/clean.js && ts-node ./downloadCurrentVersion.ts && ts-node ./verifyVersion.ts",
15-
"prepublishOnly": "npm run updateBinary npm && npm run build",
15+
"prepack": "node build/pack-publish-block.js",
16+
"build:tarball": "npm run updateBinary && npm run build && BYPASS_SAFETY_CHECK=true npm pack ./dist",
17+
"publish:tarball": "tarball=$(npm run --silent tarballName) && ls \"$tarball\" && BYPASS_SAFETY_CHECK=true npm publish \"$tarball\"",
18+
"tarballName": "jq --raw-output '.name + \"-\" + .version + \".tgz\"' package.json",
1619
"copyTestFiles": "cp -r ./test/resources ./dist/test/",
1720
"pretest": "npm run lint && npm run build && npm run copyTestFiles",
1821
"test": "cd dist && tape ./test/index.js",
@@ -32,15 +35,15 @@
3235
"node": ">=10.0.0"
3336
},
3437
"files": [
35-
"dist/abi.js",
36-
"dist/index.js",
37-
"dist/linker.js",
38-
"dist/smtchecker.js",
39-
"dist/smtsolver.js",
40-
"dist/solc.js",
41-
"dist/soljson.js",
42-
"dist/translate.js",
43-
"dist/wrapper.js"
38+
"abi.js",
39+
"index.js",
40+
"linker.js",
41+
"smtchecker.js",
42+
"smtsolver.js",
43+
"solc.js",
44+
"soljson.js",
45+
"translate.js",
46+
"wrapper.js"
4447
],
4548
"author": "chriseth",
4649
"license": "MIT",

0 commit comments

Comments
 (0)