Fix for deprecated package, that breaks publish - yet to test
Some checks failed
armco-org/Avatar/pipeline/head There was a failure building this commit

This commit is contained in:
2026-02-01 19:57:19 +05:30
parent 967ebe3731
commit d4af1b4da6
2 changed files with 18 additions and 13 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@armco/avatar",
"version": "0.0.4",
"version": "0.0.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@armco/avatar",
"version": "0.0.4",
"version": "0.0.5",
"license": "ISC",
"dependencies": {
"@armco/icon": "^0.0.13",

View File

@@ -6,18 +6,23 @@ set -e
npm --no-git-tag-version version ${semver}
npm run build
cp package.json build/
node <<'NODE'
# Use Node.js to safely normalize the copied package.json and ensure valid fields for publish
PKG_PATH="$(pwd)/build/package.json" node - <<'EOF'
const fs = require('fs');
const path = require('path');
const pkgPath = path.resolve(__dirname, 'build', 'package.json');
let content = fs.readFileSync(pkgPath, 'utf8');
content = content
.replace(/"build"/g, '"*"')
.replace(/"build\/cjs\/Avatar\.js"/g, '"cjs/Avatar.js"')
.replace(/"build\/es\/Avatar\.js"/g, '"es/Avatar.js"')
.replace(/"build\/types\/Avatar\.d\.ts"/g, '"types/Avatar.d.ts"');
fs.writeFileSync(pkgPath, content);
NODE
const p = process.env.PKG_PATH;
const pkg = JSON.parse(fs.readFileSync(p, 'utf8'));
pkg.private = false;
delete pkg.scripts;
delete pkg.devDependencies;
if (!pkg.files) pkg.files = ['*'];
else pkg.files = pkg.files.map(x => x === 'build' ? '*' : x);
['main','module','types'].forEach(k => {
if (pkg[k]) pkg[k] = pkg[k].replace(/^\.?\/?build\//, '');
});
if (pkg.deprecated && typeof pkg.deprecated !== 'string') delete pkg.deprecated;
fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n');
EOF
cd build
npm publish --access public --loglevel verbose