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

chore: add repository for all packages.json #1628

Merged
merged 1 commit into from
Jul 22, 2021
Merged

chore: add repository for all packages.json #1628

merged 1 commit into from
Jul 22, 2021

Conversation

iamandrewluca
Copy link
Contributor

If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
  "type" : "git",
  "url" : "https://github.com/facebook/react.git",
  "directory": "packages/react-dom"
}

https://docs.npmjs.com/cli/v6/configuring-npm/package-json#repository

I use a lot https://njt.vercel.app/ to jump to different packages information,
and with this PR we can know exactly what package in what folder lives

made the changes with a script to make my life easier 🙂
const { readdirSync, readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");

// CHANGE THESE
const folders = ["packages"];
const defaulUrl = "https://github.com/ueberdosis/tiptap"
const homepage = "https://www.tiptap.dev/"

folders.forEach((folder) => {
  readdirSync(folder).forEach((dir) => {
    const path = resolve(process.cwd(), folder, dir, "package.json");
    const directory = `${folder}/${dir}`
    console.log(directory)
    try {
      const package = require(path);

      package.homepage = package.homepage || homepage

      const repoInfo = typeof package.repository === 'string'
        ? { url: package.repository }
        : (package.repository || {})
      
      package.repository = {
        ...repoInfo,
        type: "git",
        url: repoInfo.url || defaulUrl,
        directory
      },

      writeFileSync(path, JSON.stringify(package, null, 2) + "\n");
    } catch (e) {
      console.log(e)
    }
  });
});

@hanspagel hanspagel merged commit 0eced7b into ueberdosis:main Jul 22, 2021
@hanspagel
Copy link
Contributor

Oh, didn’t know that. Thanks for the PR!

@iamandrewluca iamandrewluca deleted the add-repo-info branch July 23, 2021 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants