Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- name: Run Production Audit
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
Expand Down Expand Up @@ -131,10 +127,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
Expand Down Expand Up @@ -97,10 +93,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/post-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Fetch Dependabot Metadata
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Commitlint on Commits
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Set npm authToken
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Release Please
Expand Down Expand Up @@ -121,10 +117,6 @@ jobs:
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Create Release Manager Checklist Text
Expand Down
26 changes: 20 additions & 6 deletions lib/default-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,27 @@ if (!package.author) {
: yes ? '' : prompt('author')
}

const license = package.license || getConfig('license') || 'ISC'
exports.license = yes ? license : prompt('license', license, (data) => {
if (validateLicense(data)) {
return data
const configLicense = getConfig('license')
const license = package.license || configLicense || undefined

if (yes) {
// Only include license if explicitly set in config or already in package.json
if (license) {
Comment thread
owlstronaut marked this conversation as resolved.
exports.license = license
}
return invalid('Sorry, license should be a valid SPDX license expression')
})
} else {
exports.license = prompt('license', license || undefined, (data) => {
if (!data) {
return undefined
}
if (validateLicense(data)) {
return data
}
return invalid(
'License should be a valid SPDX license expression'
)
})
}

const type = package.type || getConfig('type') || 'commonjs'
exports.type = yes ? type : prompt('type', type, (data) => {
Expand Down
5 changes: 5 additions & 0 deletions lib/init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ async function init (dir,
delete pkg.content.repository
}

// if no license was explicitly provided, don't include one
if (!pzData.license) {
Comment thread
owlstronaut marked this conversation as resolved.
delete pkg.content.license
}

// readJson filters out empty descriptions, but init-package-json
// traditionally leaves them alone
if (!pkg.content.description) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.30.0",
"publish": true
"publish": true,
"updateNpm": false
}
}
1 change: 0 additions & 1 deletion test/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ t.test('read in dependencies and dev deps', async (t) => {
scripts: { test: 'mocha' },
main: 'index.js',
keywords: [],
license: 'ISC',
dependencies: {
tap: '*',
},
Expand Down
40 changes: 38 additions & 2 deletions test/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ t.test('license', async (t) => {
inputs: {
name: 'the-name',
licence: [
[/license: \(.*\) $/, 'Apache'], // invalid license
[/license: \(.*\) $/, 'Apache-2.0'], // license
[/license: $/, 'Apache'], // invalid license
[/license: $/, 'Apache-2.0'], // license
],
},
})
Expand All @@ -27,3 +27,39 @@ t.test('license', async (t) => {
}
t.has(data, wanted)
})

t.test('license omitted when left blank', async (t) => {
const { data } = await setup(t, __filename, {
inputs: {
name: 'the-name',
licence: [
[/license: $/, ''], // leave blank
],
},
})

t.equal(data.license, undefined, 'license is omitted when left blank')
})

t.test('license from config', async (t) => {
const { data } = await setup(t, __filename, {
config: { yes: 'yes', 'init-license': 'MIT' },
})

t.equal(data.license, 'MIT', 'uses configured license')
})

t.test('license preserved from existing package.json', async (t) => {
const { data } = await setup(t, __filename, {
testdir: {
'package.json': JSON.stringify({
name: 'existing-package',
version: '1.0.0',
license: 'BSD-3-Clause',
}),
},
config: { yes: 'yes' },
})

t.equal(data.license, 'BSD-3-Clause', 'preserves existing license')
})
2 changes: 0 additions & 2 deletions test/name-spaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ t.test('single space', async t => {
version: '1.0.0',
description: '',
scripts: { test: 'echo "Error: no test specified" && exit 1' },
license: 'ISC',
author: '',
main: 'index.js',
}
Expand All @@ -42,7 +41,6 @@ t.test('multiple spaces', async t => {
version: '1.0.0',
description: '',
scripts: { test: 'echo "Error: no test specified" && exit 1' },
license: 'ISC',
author: '',
main: 'index.js',
}
Expand Down
1 change: 0 additions & 1 deletion test/name-uppercase.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ t.test('uppercase', async (t) => {
version: '1.0.0',
description: '',
scripts: { test: 'echo "Error: no test specified" && exit 1' },
license: 'ISC',
author: '',
main: 'index.js',
}
Expand Down
1 change: 0 additions & 1 deletion test/scope-in-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ t.test('--yes with scope', async (t) => {
scripts: { test: 'echo "Error: no test specified" && exit 1' },
main: 'index.js',
keywords: [],
license: 'ISC',
}

const { data } = await setup(t, __filename, {
Expand Down
2 changes: 1 addition & 1 deletion test/yes-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ t.test('--yes defaults', async (t) => {
scripts: { test: 'echo "Error: no test specified" && exit 1' },
main: 'index.js',
keywords: [],
license: 'ISC',
}

const { data } = await setup(t, __filename, {
config: { yes: 'yes' },
})

t.has(data, EXPECT, 'used the default data')
t.equal(data.license, undefined, 'license is omitted by default')
})
Loading