Skip to content

Commit

Permalink
Ensure workspaced package.json is private (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
72636c authored Dec 21, 2020
1 parent 6074e53 commit c3dab88
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-books-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'skuba': patch
---

**configure:** Ensure workspaced `package.json` is private
21 changes: 21 additions & 0 deletions src/cli/configure/modules/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,25 @@ describe('packageModule', () => {
version: '0.0.0-semantically-released',
});
});

it('privatises a workspaced manifest', async () => {
const inputFiles = {
'package.json': JSON.stringify({
devDependencies: {},
scripts: {},
skuba: {},
workspaces: {},
}),
};

const outputFiles = await executeModule(
packageModule,
inputFiles,
defaultOpts,
);

const outputData = parsePackage(outputFiles['package.json']);

expect(outputData).toHaveProperty('private', true);
});
});
5 changes: 5 additions & 0 deletions src/cli/configure/modules/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export const packageModule = async ({
outputData.license ??= 'UNLICENSED';
outputData.scripts ??= {};

// Workspaces can only be enabled in private projects
if (outputData.workspaces && !outputData.private) {
outputData.private = true;
}

delete outputData.scripts.commit;
delete outputData.scripts['format:check'];
delete outputData.scripts['lint:build'];
Expand Down

0 comments on commit c3dab88

Please sign in to comment.