[FIX] package: Auto-update package-lock.json

This commit updates the version in package-lock.json and make it so
it is automatically and correctly updated at each new release.
This commit is contained in:
Julien Carion (juca)
2023-03-31 11:53:54 +02:00
committed by Sam Degueldre
parent 64de716b91
commit 94ae940e82
3 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@odoo/owl",
"version": "2.0.9",
"version": "2.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,2 +1,2 @@
// do not modify manually. This value is updated by the release script.
// do not modify manually. This file is generated by the release script.
export const version = "2.1.0";
+6 -7
View File
@@ -1,4 +1,5 @@
const package = require("../package.json");
const packageLock = require("../package-lock.json");
const readline = require("readline");
const fs = require("fs");
const exec = require("child_process").exec;
@@ -41,7 +42,6 @@ async function startRelease() {
// ---------------------------------------------------------------------------
log(`Step 1/${STEPS}: collecting info...`);
const current = package.version;
let next = await ask("Next version: ");
if (next[0] === 'v') next = next.substring(1);
let file = await ask(`Release notes (${REL_NOTES_FILE}): `);
@@ -85,8 +85,9 @@ async function startRelease() {
// ---------------------------------------------------------------------------
log(`Step 3/${STEPS}: updating package.json...`);
await replaceInFile("./package.json", current, next);
await replaceInFile("./src/version.ts", current, next);
await writeFile("package.json", JSON.stringify({...package, version: next}, null, 2) + "\n");
await writeFile("package-lock.json", JSON.stringify({...packageLock, version: next}, null, 2) + "\n");
await writeFile("./src/version.ts", `// do not modify manually. This file is generated by the release script.\nexport const version = "${next}";\n`);
// ---------------------------------------------------------------------------
log(`Step 4/${STEPS}: creating git commit...`);
@@ -246,11 +247,9 @@ function readFile(file) {
});
}
async function replaceInFile(file, from, to) {
const content = await readFile(file);
function writeFile(file, content) {
return new Promise((resolve, reject) => {
const updatedContent = content.replace(new RegExp(from, "g"), to);
fs.writeFile(file, updatedContent, "utf8", err => {
fs.writeFile(file, content, "utf8", err => {
if (err) {
reject(err);
} else {