Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: omit redundant pkgjson fields on publishing #1003

Closed
antongolub opened this issue Dec 17, 2024 · 3 comments · Fixed by #1005
Closed

build: omit redundant pkgjson fields on publishing #1003

antongolub opened this issue Dec 17, 2024 · 3 comments · Fixed by #1005
Labels
ossln24 OSS Library Night 2024

Comments

@antongolub
Copy link
Collaborator

antongolub commented Dec 17, 2024

Smth like clean-publish is required but w/o overengineering. Simple scripts/clean-pkg-json.mjs seems enough.

  1. We use bundling, so there's no need to keep any deps except the optionalDependencies
  2. Prettier config section should be flushed
  3. We dont have pre or post-install scripts, so the whole section can be dropped
@easymikey
Copy link
Contributor

How to use prettier in this case? Create other config or use default config settings?

@antongolub
Copy link
Collaborator Author

antongolub commented Dec 17, 2024

npm-publish.yml

...
- run: node scripts/clean-pkg-json.mjs
- run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
  env:
    AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
- run: npm publish --provenance --access=public

Or even:

{
   "prepublish": "node scripts/clean-pkg-json.mjs"
}

scripts/clean-pkg-json.mjs

import fs from 'node:fs'
import path from 'node:path'

const __dirname = // ...
const filepath = path.resolve(__dirname, '../package.json')

const pkgJson = JSON.parse(fs.readFileSync(filepath))
const cleaned = {
   ...pkgJson,
   prettier: undefined,
   scripts: undefined,
   devDependencies: undefined
}

fs.writeFileSync(filepath, JSON.stringify(filepath, null, 2))

@easymikey
Copy link
Contributor

easymikey commented Dec 18, 2024

This look so easy. I'll do it during the day, assign to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ossln24 OSS Library Night 2024
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants