Skip to content

Commit

Permalink
fix(release): add public access for npm release when public option …
Browse files Browse the repository at this point in the history
…is used

The public access, `publishConfig` value, in the `package.json` is needed to publish a scoped package to the npmjs registry.
  • Loading branch information
jdbruijn committed Oct 24, 2023
1 parent e912a31 commit 815d347
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/content/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('sets "files" to non-test files in dist', (t) => {

const includes = test.macro<[boolean, keyof PackageJson, keyof Options]>({
async exec(t, include, value, option) {
if (option === 'public' ? !include : include) {
if (include) {
t.not(packageJson({[option]: include})[value], undefined);
} else {
t.is(packageJson({[option]: include})[value], undefined);
Expand All @@ -47,8 +47,11 @@ const includes = test.macro<[boolean, keyof PackageJson, keyof Options]>({
test('sets "private" to "true" without "public" option', (t) => {
t.is(packageJson({public: false}).private, true);
});
test(includes, true, 'private', 'public');
test(includes, false, 'private', 'public');
test('does not include "private" with "public" option', (t) => {
t.is(packageJson({public: true}).private, undefined);
});
test(includes, true, 'publishConfig', 'public');
test(includes, false, 'publishConfig', 'public');
test(includes, true, 'exports', 'typescript');
test(includes, false, 'exports', 'typescript');
test(includes, true, 'files', 'typescript');
Expand Down
6 changes: 5 additions & 1 deletion src/content/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ const schema = z
dependencies: z.record(z.string()).optional(),
devDependencies: z.record(z.string()),
engines: z.object({node: z.literal('>=18')}).strict(),
publishConfig: z.object({access: z.literal('public')}).strict(),
publishConfig: z
.object({access: z.literal('public')})
.strict()
.optional(),
})
.strict();

Expand Down Expand Up @@ -85,6 +88,7 @@ class Package extends File {
delete this._package.private;
} else {
this._package.private = true;
delete this._package.publishConfig;
}

const devDependencies = [
Expand Down

0 comments on commit 815d347

Please sign in to comment.