Skip to content

Commit

Permalink
Add dependenciesMeta.*.injected: true to test-app
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 31, 2023
1 parent f32a9c4 commit 30f8b64
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module.exports = {

if (options.pnpm) {
tasks.push(pnpm.createWorkspacesFile(options.target, addonInfo, testAppInfo));
tasks.push(pnpm.handleImperfections(addonInfo, testAppInfo));
}

if (options.releaseIt) {
Expand Down
27 changes: 27 additions & 0 deletions src/pnpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const fs = require('fs/promises');
const path = require('path');
const fse = require('fs-extra');

/**
* @typedef {import('./types').AddonInfo} AddonInfo
Expand All @@ -19,6 +20,32 @@ async function createWorkspacesFile(targetPath, addonInfo, testAppInfo) {
await fs.writeFile(path.join(targetPath, 'pnpm-workspace.yaml'), content);
}

/**
*
* @param {AddonInfo} addonInfo
* @param {TestAppInfo} testAppInfo
*/
async function handleImperfections(addonInfo, testAppInfo) {
/**
* https://github.com/pnpm/pnpm/issues/4965#issuecomment-1405264290
*
* for dependencies in a monorepo, AND when peerDependencies need to be resolved correctly,
* the dependencies must use `dependenciesMeta.*.injected: true`,
*
* more info here:
* https://pnpm.io/package_json#dependenciesmetainjected
*/
let testAppPackageJsonPath = path.join(testAppInfo.location, 'package.json');
let testAppPackageJson = await fse.readJSON(testAppPackageJsonPath);

testAppPackageJson.dependenciesMeta = {
[addonInfo.name.dashed]: {
injected: true,
},
};
}

module.exports = {
createWorkspacesFile,
handleImperfections,
};

0 comments on commit 30f8b64

Please sign in to comment.