Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add content config option to allow a module to set own content #189

Merged
merged 2 commits into from Sep 15, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/audit.yml
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
audit:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -17,6 +17,7 @@ on:

jobs:
lint:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -34,6 +35,7 @@ jobs:
- run: npm run lint

test:
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-dependabot.yml
Expand Up @@ -10,8 +10,8 @@ permissions:

jobs:
template-oss-apply:
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Expand Up @@ -13,6 +13,7 @@ on:
jobs:
check:
name: Check PR Title or Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release-please.yml
Expand Up @@ -14,10 +14,11 @@ permissions:

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
pr: ${{ steps.release.outputs.pr }}
release: ${{ steps.release.outputs.release }}
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup git user
Expand Down Expand Up @@ -73,13 +74,13 @@ jobs:
release-test:
needs: post-pr
if: needs.post-pr.outputs.ref
uses: ./.github/workflows/release-test.yml
uses: ./.github/workflows/release.yml
with:
ref: ${{ needs.post-pr.outputs.ref }}

post-release:
needs: release-please
if: needs.release-please.outputs.release
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
lint-all:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -27,9 +28,10 @@ jobs:
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm run lint --if-present --workspaces --include-workspace-root
- run: npm run lint -ws -iwr --if-present

test-all:
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -83,4 +85,4 @@ jobs:
- run: npm i --ignore-scripts --no-audit --no-fund
- name: add tap problem matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- run: npm run test --if-present --workspaces --include-workspace-root
- run: npm run test -ws -iwr --if-present
22 changes: 11 additions & 11 deletions .gitignore
Expand Up @@ -4,25 +4,25 @@
/*

# keep these
!/.eslintrc.local.*
!**/.gitignore
!/docs/
!/tap-snapshots/
!/test/
!/map.js
!/scripts/
!/README*
!/LICENSE*
!/CHANGELOG*
!/.commitlintrc.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.github/
!/.gitignore
!/.npmrc
!/.release-please-manifest.json
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/CHANGELOG*
!/CODE_OF_CONDUCT.md
!/docs/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/README*
!/release-please-config.json
!/scripts/
!/SECURITY.md
!/tap-snapshots/
!/test/
2 changes: 1 addition & 1 deletion lib/apply/apply-files.js
Expand Up @@ -3,7 +3,7 @@ const log = require('proc-log')
const { rmEach, parseEach } = require('../util/files.js')

const run = async (dir, files, options) => {
const { rm = [], add = {} } = files
const { rm, add } = files

log.verbose('apply-files', 'rm', rm)
await rmEach(dir, rm, options, (f) => fs.rm(f))
Expand Down
2 changes: 1 addition & 1 deletion lib/apply/index.js
@@ -1,6 +1,6 @@
const run = require('../index.js')

module.exports = (root, content) => run(root, content, [
module.exports = (root) => run(root, [
require('./apply-files.js'),
require('./apply-version.js'),
])
9 changes: 5 additions & 4 deletions lib/check/check-apply.js
Expand Up @@ -2,13 +2,14 @@ const log = require('proc-log')
const { relative, basename } = require('path')
const { rmEach, parseEach } = require('../util/files.js')
const { partition } = require('lodash')
const localeCompare = require('@isaacs/string-locale-compare')('en')

const solution = 'npx template-oss-apply --force'

const run = async (type, dir, files, options) => {
const res = []
const rel = (f) => relative(options.root, f)
const { add: addFiles = {}, rm: rmFiles = [] } = files
const { add: addFiles, rm: rmFiles } = files

const rm = await rmEach(dir, rmFiles, options, (f) => rel(f))
const [add, update] = partition(await parseEach(dir, addFiles, options, async (p) => {
Expand All @@ -28,7 +29,7 @@ const run = async (type, dir, files, options) => {
if (rm.length) {
res.push({
title: `The following ${type} files need to be deleted:`,
body: rm,
body: rm.sort(localeCompare),
solution,
})
}
Expand All @@ -37,13 +38,13 @@ const run = async (type, dir, files, options) => {
if (add.length) {
res.push({
title: `The following ${type} files need to be added:`,
body: add,
body: add.sort(localeCompare),
solution,
})
}

log.verbose('check-apply', 'update', update)
res.push(...update.map(({ file, diff }) => ({
res.push(...update.sort((a, b) => localeCompare(a.file, b.file)).map(({ file, diff }) => ({
title: `The ${type} file ${basename(file)} needs to be updated:`,
body: [`${file}\n${'='.repeat(40)}\n${diff}`],
solution,
Expand Down
2 changes: 1 addition & 1 deletion lib/check/index.js
@@ -1,6 +1,6 @@
const run = require('../index.js')

module.exports = (root, content) => run(root, content, [
module.exports = (root) => run(root, [
require('./check-apply.js'),
require('./check-required.js'),
require('./check-unwanted.js'),
Expand Down