From 75a927750a140f0685550bd7697bad9b53adfec0 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:54:05 +0900 Subject: [PATCH] feat(init): support provenance publishing See https://github.blog/changelog/2023-04-19-npm-provenance-public-beta/ --- lib/init.js | 3 ++- package.json | 3 +++ test/__snapshots__/init.test.js.snap | 7 +++++++ test/fixtures/package-normal.json | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/init.js b/lib/init.js index aaed7d43..7342988d 100644 --- a/lib/init.js +++ b/lib/init.js @@ -92,7 +92,7 @@ const initCommand = (baseDir, logger) => { } /** - * @param {"lint-staged" | "standard-version" | "remarkConfig"} key + * @param {string} key */ const updateOtherKey = (key) => { if (!(key in packageInfo)) { @@ -100,6 +100,7 @@ const initCommand = (baseDir, logger) => { } Object.assign(packageInfo[key], originalPackage[key]); }; + updateOtherKey("publishConfig"); updateOtherKey("lint-staged"); updateOtherKey("standard-version"); updateOtherKey("remarkConfig"); diff --git a/package.json b/package.json index c887e3da..731d6c26 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,9 @@ "engines": { "node": ">=16.0.0" }, + "publishConfig": { + "provenance": true + }, "dependencies": { "@commitlint/cli": "^17.6.1", "@commitlint/config-conventional": "^17.6.1", diff --git a/test/__snapshots__/init.test.js.snap b/test/__snapshots__/init.test.js.snap index 87391144..ab24b482 100644 --- a/test/__snapshots__/init.test.js.snap +++ b/test/__snapshots__/init.test.js.snap @@ -32,6 +32,10 @@ exports[`update "package.json" 1`] = ` "*.css": "xyz", "*.{js,jsx,cjs,mjs,ts,tsx}": "eslint --cache --fix", }, + "publishConfig": { + "access": true, + "provenance": true, + }, "remarkConfig": { "plugins": [ "remark-preset-ybiquitous", @@ -100,6 +104,9 @@ exports[`update "package.json" without fields 1`] = ` "!(CHANGELOG).md": "remark --frail", "*.{js,jsx,cjs,mjs,ts,tsx}": "eslint --cache --fix", }, + "publishConfig": { + "provenance": true, + }, "remarkConfig": { "plugins": [ "remark-preset-ybiquitous", diff --git a/test/fixtures/package-normal.json b/test/fixtures/package-normal.json index c12705de..7acd9131 100644 --- a/test/fixtures/package-normal.json +++ b/test/fixtures/package-normal.json @@ -3,6 +3,9 @@ "test": "abc", "lint:js": "eslint ." }, + "publishConfig": { + "access": true + }, "lint-staged": { "*.css": "xyz" },