Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "pvu", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "packages version update", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
33
pvu.js
#!/usr/bin/env node | ||
'use strict'; | ||
"use strict"; | ||
const args = require('args'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const args = require("args"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const { splitUnit } = require("@daybrush/utils"); | ||
const { shell } = require('./utils'); | ||
const { shell } = require("./utils"); | ||
args | ||
.option('path', 'package folder', "packages") | ||
.option('packages', 'packages', "") | ||
.option("path", "package folder", "packages") | ||
.option("packages", "packages", ""); | ||
@@ -19,3 +19,2 @@ const { | ||
const cwd = process.cwd(); | ||
@@ -26,7 +25,6 @@ const { name, version } = JSON.parse(fs.readFileSync(path.resolve(cwd, "package.json"), { encoding: "utf8" })); | ||
packages.split(",").forEach(packagePath => { | ||
const packageFullPath = path.resolve(packagesPath, packagePath); | ||
const packageJSONPath = ath.resolve(packageFullPath, "package.json"); | ||
const packageJSON = fs.readFileSync(packageJSONPath); | ||
const packagesFullPath = path.resolve(packagesPath, packagePath); | ||
const packageJSONPath = path.resolve(packagesFullPath, "package.json"); | ||
const packageJSON = fs.readFileSync(packageJSONPath, { encoding: "utf-8" }); | ||
const | ||
const { | ||
@@ -38,6 +36,6 @@ version: packageVersion, | ||
} = JSON.parse(packageJSON); | ||
const originalVersions = originalVersion.split("."); | ||
const originalVersions = originalVersion.replace(/^[^\d]?/g, "").split("."); | ||
const packageVersions = packageVersion.split("."); | ||
const changedIndex = originalVersions.find((v, i) => v !== verions[i]); | ||
const changedIndex = originalVersions.findIndex((v, i) => v !== versions[i]); | ||
@@ -47,3 +45,3 @@ if (changedIndex === -1) { | ||
} | ||
const ov = splitUnit(originalVerions[changedIndex]); | ||
const ov = splitUnit(originalVersions[changedIndex]); | ||
const vv = splitUnit(versions); | ||
@@ -60,5 +58,6 @@ | ||
} | ||
const relativePath = path.relative(cwd, packagesFullPath); | ||
fs.writeFileSync(packageJSONPath, packageJSON.replace(packageVersion, packageVersions.join(".")), { encoding: "utf-8" }); | ||
shell(`cd ${packageFullPath} && npm i ${name}@latest`); | ||
shell(`cd ${packageFullPath.split("/").map(v => v ? ".." : "").join("/")}/`); | ||
shell(`cd ${relativePath} && npm i ${name}@latest`); | ||
shell(`cd ${relativePath.split("/").map(v => v ? ".." : "").join("/")}/`); | ||
}); |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3833