[feat] modify package.json

This commit is contained in:
Jay 2020-09-11 13:18:42 +08:00
parent 0aca86cfa3
commit a8f36b2923
5 changed files with 80 additions and 31 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@mtfos/rs-diff-darwin",
"version": "0.0.5",
"version": "0.0.6",
"description": "Template project for writing node package with napi-rs",
"repository": "https://git.trj.tw/nodejs/rs-diff.git",
"license": "MIT",

View File

@ -1,6 +1,6 @@
{
"name": "@mtfos/rs-diff-linux",
"version": "0.0.5",
"version": "0.0.6",
"description": "Template project for writing node package with napi-rs",
"repository": "https://git.trj.tw/nodejs/rs-diff.git",
"license": "MIT",

58
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@mtfos/rs-diff",
"version": "0.0.5",
"version": "0.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -99,12 +99,6 @@
}
}
},
"@mtfos/rs-diff-linux": {
"version": "0.0.4",
"resolved": "https://npm.trj.tw/@mtfos%2frs-diff-linux/-/rs-diff-linux-0.0.4.tgz",
"integrity": "sha512-Cm8k1LpMAt9t3DC1E3joTMMPmg+8xipjxfhF3BQqXppH/THmlk4zrxwRSTRlsME3rrZ5xq3d1TNDdZ9wXSn+Jg==",
"optional": true
},
"@node-rs/helper": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-0.4.0.tgz",
@ -874,6 +868,26 @@
"integrity": "sha1-fj5Iu+bZl7FBfdyihoIEtNPYVxU=",
"dev": true
},
"cross-env": {
"version": "7.0.2",
"resolved": "https://npm.trj.tw/cross-env/-/cross-env-7.0.2.tgz",
"integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.1"
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://npm.trj.tw/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"crypto-random-string": {
"version": "2.0.0",
"resolved": "https://npm.trj.tw/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@ -1963,6 +1977,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"path-key": {
"version": "3.1.1",
"resolved": "https://npm.trj.tw/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://npm.trj.tw/path-parse/-/path-parse-1.0.6.tgz",
@ -2384,6 +2404,21 @@
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"dev": true
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://npm.trj.tw/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://npm.trj.tw/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"signal-exit": {
"version": "3.0.3",
"resolved": "https://npm.trj.tw/signal-exit/-/signal-exit-3.0.3.tgz",
@ -2747,6 +2782,15 @@
"integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==",
"dev": true
},
"which": {
"version": "2.0.2",
"resolved": "https://npm.trj.tw/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "https://npm.trj.tw/which-module/-/which-module-2.0.0.tgz",

View File

@ -32,12 +32,14 @@
"scripts": {
"build": "cargo build --release && napi build --platform --release .",
"build:debug": "cargo build && napi build --platform .",
"prepublishOnly": "node ./scripts/publish.js",
"test": "ava",
"publish:linux": "cross-env PLATFORM=linux node scripts/publish.js",
"publish:darwin": "cross-env PLATFORM=darwin node scripts/publish.js",
"version": "node ./scripts/version.js"
},
"devDependencies": {
"ava": "^3.11.1",
"cross-env": "^7.0.2",
"napi-rs": "^0.3.7",
"typescript": "^3.9.7"
},
@ -45,7 +47,7 @@
"@node-rs/helper": "^0.4.0"
},
"optionalDependencies": {
"@mtfos/rs-diff-darwin": "^0.0.5",
"@mtfos/rs-diff-linux": "^0.0.5"
"@mtfos/rs-diff-darwin": "^0.0.6",
"@mtfos/rs-diff-linux": "^0.0.6"
}
}
}

View File

@ -1,28 +1,31 @@
const { execSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const platforms = require('./platforms')
const updatePackageJson = require('./update-package')
const platforms = require("./platforms");
const updatePackageJson = require("./update-package");
const { version } = require('../package.json')
const { version } = require("../package.json");
updatePackageJson(path.join(__dirname, '..', 'package.json'), {
updatePackageJson(path.join(__dirname, "..", "package.json"), {
optionalDependencies: platforms.reduce((acc, cur) => {
acc[`@mtfos/rs-diff-${cur}`] = `^${version}`
return acc
acc[`@mtfos/rs-diff-${cur}`] = `^${version}`;
return acc;
}, {}),
})
});
const envPlatform = process.env.PLATFORM || "";
for (const name of platforms) {
const pkgDir = path.join(__dirname, '..', 'npm', name)
const filename = `index.${name}.node`
if (!fs.existsSync(path.join(__dirname, '..', filename))) continue
const bindingFile = fs.readFileSync(path.join(__dirname, '..', filename))
fs.writeFileSync(path.join(pkgDir, filename), bindingFile)
execSync('npm publish', {
if (envPlatform && name !== envPlatform) continue;
const pkgDir = path.join(__dirname, "..", "npm", name);
const filename = `index.${name}.node`;
if (!fs.existsSync(path.join(__dirname, "..", filename))) continue;
const bindingFile = fs.readFileSync(path.join(__dirname, "..", filename));
fs.writeFileSync(path.join(pkgDir, filename), bindingFile);
execSync("npm publish", {
cwd: pkgDir,
env: process.env,
stdio: 'inherit',
})
stdio: "inherit",
});
}