diff --git a/src/check-project/check-monorepo-readme.js b/src/check-project/check-monorepo-readme.js index 05ced0f74..e71deaedd 100644 --- a/src/check-project/check-monorepo-readme.js +++ b/src/check-project/check-monorepo-readme.js @@ -15,11 +15,12 @@ import { /** * @param {string} projectDir * @param {string} repoUrl + * @param {string} webRoot * @param {string} defaultBranch * @param {string[]} projectDirs * @param {string} ciFile */ -export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, projectDirs, ciFile) { +export async function checkMonorepoReadme (projectDir, repoUrl, webRoot, defaultBranch, projectDirs, ciFile) { const repoParts = repoUrl.split('/') const repoName = repoParts.pop() const repoOwner = repoParts.pop() @@ -146,7 +147,7 @@ export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, p other.push(child) }) - const license = parseMarkdown(LICENSE(pkg, repoOwner, repoName, defaultBranch)) + const license = parseMarkdown(LICENSE(pkg, repoOwner, repoName, webRoot, defaultBranch)) /** @type {import('mdast').Root} */ let apiDocs = { diff --git a/src/check-project/check-readme.js b/src/check-project/check-readme.js index e9aa4c531..609f24ce6 100644 --- a/src/check-project/check-readme.js +++ b/src/check-project/check-readme.js @@ -14,11 +14,12 @@ import { /** * @param {string} projectDir * @param {string} repoUrl + * @param {string} webRoot * @param {string} defaultBranch * @param {string} ciFile * @param {any} [rootManifest] */ -export async function checkReadme (projectDir, repoUrl, defaultBranch, ciFile, rootManifest) { +export async function checkReadme (projectDir, repoUrl, webRoot, defaultBranch, ciFile, rootManifest) { const repoParts = repoUrl.split('/') const repoName = repoParts.pop() const repoOwner = repoParts.pop() @@ -162,7 +163,7 @@ export async function checkReadme (projectDir, repoUrl, defaultBranch, ciFile, r apiDocs = parseMarkdown(APIDOCS(pkg, rootManifest)) } - const license = parseMarkdown(LICENSE(pkg, repoOwner, repoName, defaultBranch)) + const license = parseMarkdown(LICENSE(pkg, repoOwner, repoName, webRoot, defaultBranch)) readme.children = [ ...header, diff --git a/src/check-project/index.js b/src/check-project/index.js index b7eecc885..89fccbb12 100755 --- a/src/check-project/index.js +++ b/src/check-project/index.js @@ -148,13 +148,15 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl, ciFil let proposedManifest = await monorepoManifest(manifest, repoUrl, repoUrl, branchName) proposedManifest = sortManifest(proposedManifest) + const webRoot = `${repoUrl}/tree/${branchName}` + await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2)) await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), { encoding: 'utf-8' })) await checkLicenseFiles(projectDir) await checkBuildFiles(projectDir, branchName, repoUrl) - await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs, ciFile) + await checkMonorepoReadme(projectDir, repoUrl, webRoot, branchName, projectDirs, ciFile) await checkMonorepoFiles(projectDir) } @@ -386,17 +388,20 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag const { projectType } = await prompt.get({ properties: { projectType: { - description: 'Project type: typescript | typedESM | typedCJS | untypedESM | untypedCJS', + description: 'Project type: typescript | typedESM | typedCJS | untypedESM | untypedCJS | skip', required: true, conform: (value) => { - return ['typescript', 'typedESM', 'typedCJS', 'untypedESM', 'untypedCJS'].includes(value) + return ['typescript', 'typedESM', 'typedCJS', 'untypedESM', 'untypedCJS', 'skip'].includes(value) }, - default: 'typescript' + default: 'skip' } } }) - if (projectType === 'typescript') { + if (projectType === 'skip') { + console.info('Skipping', manifest.name) + return + } else if (projectType === 'typescript') { typescript = true } else if (projectType === 'typedESM') { typedESM = true @@ -447,7 +452,7 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag } await checkLicenseFiles(projectDir) - await checkReadme(projectDir, repoUrl, branchName, ciFile, rootManifest) + await checkReadme(projectDir, repoUrl, homePage, branchName, ciFile, rootManifest) await checkTypedocFiles(projectDir, typescript) } diff --git a/src/check-project/readme/license.js b/src/check-project/readme/license.js index 1a5adf233..c57523632 100644 --- a/src/check-project/readme/license.js +++ b/src/check-project/readme/license.js @@ -1,14 +1,14 @@ /** - * @type {Record string>} + * @type {Record string>} */ const licenses = { - ipfs: (repoOwner, repoName, defaultBranch) => ` + ipfs: (repoOwner, repoName, webRoot, defaultBranch) => ` # License Licensed under either of - * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) - * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) + * Apache 2.0, ([LICENSE-APACHE](${webRoot.replace('/tree/', '/blob/')}/LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) + * MIT ([LICENSE-MIT](${webRoot.replace('/tree/', '/blob/')}/LICENSE-MIT) / http://opensource.org/licenses/MIT) # Contribute @@ -22,13 +22,13 @@ Unless you explicitly state otherwise, any contribution intentionally submitted [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) `, - default: (repoOwner, repoName, defaultBranch) => ` + default: (repoOwner, repoName, webRoot, defaultBranch) => ` # License Licensed under either of - * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) - * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) + * Apache 2.0, ([LICENSE-APACHE](${webRoot.replace('/tree/', '/blob/')}/LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) + * MIT ([LICENSE-MIT](${webRoot.replace('/tree/', '/blob/')}/LICENSE-MIT) / http://opensource.org/licenses/MIT) # Contribution @@ -40,8 +40,9 @@ Unless you explicitly state otherwise, any contribution intentionally submitted * @param {*} pkg * @param {string} repoOwner * @param {string} repoName + * @param {string} webRoot * @param {string} defaultBranch */ -export const LICENSE = (pkg, repoOwner, repoName, defaultBranch) => { - return (licenses[repoOwner] ?? licenses.default)(repoOwner, repoName, defaultBranch) +export const LICENSE = (pkg, repoOwner, repoName, webRoot, defaultBranch) => { + return (licenses[repoOwner] ?? licenses.default)(repoOwner, repoName, webRoot, defaultBranch) }