From 72064ddddabed9daf05120faccc3fd38105fd929 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 14 Sep 2023 14:29:43 -0500 Subject: [PATCH 1/4] Add .handlebars suffix to template files --- .eslintrc.local.json | 6 --- .github/ISSUE_TEMPLATE/config.yml.handlebars | 3 ++ .../{CODEOWNERS => CODEOWNERS.handlebars} | 0 ...NDUCT.md => CODE_OF_CONDUCT.md.handlebars} | 0 ...RIBUTING.md => CONTRIBUTING.md.handlebars} | 0 .../{LICENSE.md => LICENSE.md.handlebars} | 0 .../{SECURITY.md => SECURITY.md.handlebars} | 0 ...-matrix.yml => _job-matrix.yml.handlebars} | 0 ...> _job-release-integration.yml.handlebars} | 0 lib/content/{_job.yml => _job.yml.handlebars} | 0 .../{_on-ci.yml => _on-ci.yml.handlebars} | 0 ...p-audit.yml => _step-audit.yml.handlebars} | 0 ...checks.yml => _step-checks.yml.handlebars} | 0 ...tep-deps.yml => _step-deps.yml.handlebars} | 0 ..._step-git.yml => _step-git.yml.handlebars} | 0 ...tep-lint.yml => _step-lint.yml.handlebars} | 0 ...tep-node.yml => _step-node.yml.handlebars} | 0 ...tep-test.yml => _step-test.yml.handlebars} | 0 ...-setup.yml => _steps-setup.yml.handlebars} | 0 .../{audit.yml => audit.yml.handlebars} | 0 lib/content/{bug.yml => bug.yml.handlebars} | 0 ...-release.yml => ci-release.yml.handlebars} | 0 lib/content/{ci.yml => ci.yml.handlebars} | 0 ...sis.yml => codeql-analysis.yml.handlebars} | 0 ...itlintrc.js => commitlintrc.js.handlebars} | 0 .../{config.yml => config.yml.handlebars} | 0 ...pendabot.yml => dependabot.yml.handlebars} | 0 .../{eslintrc.js => eslintrc.js.handlebars} | 0 .../{gitignore => gitignore.handlebars} | 0 lib/content/index.js | 52 +++++++++---------- lib/content/{npmrc => npmrc.handlebars} | 0 lib/content/{pkg.json => pkg.json.handlebars} | 0 ...bot.yml => post-dependabot.yml.handlebars} | 0 ...equest.yml => pull-request.yml.handlebars} | 0 ... => release-please-config.json.handlebars} | 0 ...> release-please-manifest.json.handlebars} | 0 .../{release.yml => release.yml.handlebars} | 0 .../{settings.yml => settings.yml.handlebars} | 0 lib/content/{tap.json => tap.json.handlebars} | 0 lib/util/template.js | 3 +- test/apply/index.js | 2 +- 41 files changed, 32 insertions(+), 34 deletions(-) delete mode 100644 .eslintrc.local.json create mode 100644 .github/ISSUE_TEMPLATE/config.yml.handlebars rename lib/content/{CODEOWNERS => CODEOWNERS.handlebars} (100%) rename lib/content/{CODE_OF_CONDUCT.md => CODE_OF_CONDUCT.md.handlebars} (100%) rename lib/content/{CONTRIBUTING.md => CONTRIBUTING.md.handlebars} (100%) rename lib/content/{LICENSE.md => LICENSE.md.handlebars} (100%) rename lib/content/{SECURITY.md => SECURITY.md.handlebars} (100%) rename lib/content/{_job-matrix.yml => _job-matrix.yml.handlebars} (100%) rename lib/content/{_job-release-integration.yml => _job-release-integration.yml.handlebars} (100%) rename lib/content/{_job.yml => _job.yml.handlebars} (100%) rename lib/content/{_on-ci.yml => _on-ci.yml.handlebars} (100%) rename lib/content/{_step-audit.yml => _step-audit.yml.handlebars} (100%) rename lib/content/{_step-checks.yml => _step-checks.yml.handlebars} (100%) rename lib/content/{_step-deps.yml => _step-deps.yml.handlebars} (100%) rename lib/content/{_step-git.yml => _step-git.yml.handlebars} (100%) rename lib/content/{_step-lint.yml => _step-lint.yml.handlebars} (100%) rename lib/content/{_step-node.yml => _step-node.yml.handlebars} (100%) rename lib/content/{_step-test.yml => _step-test.yml.handlebars} (100%) rename lib/content/{_steps-setup.yml => _steps-setup.yml.handlebars} (100%) rename lib/content/{audit.yml => audit.yml.handlebars} (100%) rename lib/content/{bug.yml => bug.yml.handlebars} (100%) rename lib/content/{ci-release.yml => ci-release.yml.handlebars} (100%) rename lib/content/{ci.yml => ci.yml.handlebars} (100%) rename lib/content/{codeql-analysis.yml => codeql-analysis.yml.handlebars} (100%) rename lib/content/{commitlintrc.js => commitlintrc.js.handlebars} (100%) rename lib/content/{config.yml => config.yml.handlebars} (100%) rename lib/content/{dependabot.yml => dependabot.yml.handlebars} (100%) rename lib/content/{eslintrc.js => eslintrc.js.handlebars} (100%) rename lib/content/{gitignore => gitignore.handlebars} (100%) rename lib/content/{npmrc => npmrc.handlebars} (100%) rename lib/content/{pkg.json => pkg.json.handlebars} (100%) rename lib/content/{post-dependabot.yml => post-dependabot.yml.handlebars} (100%) rename lib/content/{pull-request.yml => pull-request.yml.handlebars} (100%) rename lib/content/{release-please-config.json => release-please-config.json.handlebars} (100%) rename lib/content/{release-please-manifest.json => release-please-manifest.json.handlebars} (100%) rename lib/content/{release.yml => release.yml.handlebars} (100%) rename lib/content/{settings.yml => settings.yml.handlebars} (100%) rename lib/content/{tap.json => tap.json.handlebars} (100%) diff --git a/.eslintrc.local.json b/.eslintrc.local.json deleted file mode 100644 index a3e78e7e..00000000 --- a/.eslintrc.local.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "ignorePatterns": [ - "lib/content/*", - "!lib/content/index.js" - ] -} diff --git a/.github/ISSUE_TEMPLATE/config.yml.handlebars b/.github/ISSUE_TEMPLATE/config.yml.handlebars new file mode 100644 index 00000000..571fd5ff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml.handlebars @@ -0,0 +1,3 @@ +This file is automatically added by @npmcli/template-oss. Do not edit. + +blank_issues_enabled: true diff --git a/lib/content/CODEOWNERS b/lib/content/CODEOWNERS.handlebars similarity index 100% rename from lib/content/CODEOWNERS rename to lib/content/CODEOWNERS.handlebars diff --git a/lib/content/CODE_OF_CONDUCT.md b/lib/content/CODE_OF_CONDUCT.md.handlebars similarity index 100% rename from lib/content/CODE_OF_CONDUCT.md rename to lib/content/CODE_OF_CONDUCT.md.handlebars diff --git a/lib/content/CONTRIBUTING.md b/lib/content/CONTRIBUTING.md.handlebars similarity index 100% rename from lib/content/CONTRIBUTING.md rename to lib/content/CONTRIBUTING.md.handlebars diff --git a/lib/content/LICENSE.md b/lib/content/LICENSE.md.handlebars similarity index 100% rename from lib/content/LICENSE.md rename to lib/content/LICENSE.md.handlebars diff --git a/lib/content/SECURITY.md b/lib/content/SECURITY.md.handlebars similarity index 100% rename from lib/content/SECURITY.md rename to lib/content/SECURITY.md.handlebars diff --git a/lib/content/_job-matrix.yml b/lib/content/_job-matrix.yml.handlebars similarity index 100% rename from lib/content/_job-matrix.yml rename to lib/content/_job-matrix.yml.handlebars diff --git a/lib/content/_job-release-integration.yml b/lib/content/_job-release-integration.yml.handlebars similarity index 100% rename from lib/content/_job-release-integration.yml rename to lib/content/_job-release-integration.yml.handlebars diff --git a/lib/content/_job.yml b/lib/content/_job.yml.handlebars similarity index 100% rename from lib/content/_job.yml rename to lib/content/_job.yml.handlebars diff --git a/lib/content/_on-ci.yml b/lib/content/_on-ci.yml.handlebars similarity index 100% rename from lib/content/_on-ci.yml rename to lib/content/_on-ci.yml.handlebars diff --git a/lib/content/_step-audit.yml b/lib/content/_step-audit.yml.handlebars similarity index 100% rename from lib/content/_step-audit.yml rename to lib/content/_step-audit.yml.handlebars diff --git a/lib/content/_step-checks.yml b/lib/content/_step-checks.yml.handlebars similarity index 100% rename from lib/content/_step-checks.yml rename to lib/content/_step-checks.yml.handlebars diff --git a/lib/content/_step-deps.yml b/lib/content/_step-deps.yml.handlebars similarity index 100% rename from lib/content/_step-deps.yml rename to lib/content/_step-deps.yml.handlebars diff --git a/lib/content/_step-git.yml b/lib/content/_step-git.yml.handlebars similarity index 100% rename from lib/content/_step-git.yml rename to lib/content/_step-git.yml.handlebars diff --git a/lib/content/_step-lint.yml b/lib/content/_step-lint.yml.handlebars similarity index 100% rename from lib/content/_step-lint.yml rename to lib/content/_step-lint.yml.handlebars diff --git a/lib/content/_step-node.yml b/lib/content/_step-node.yml.handlebars similarity index 100% rename from lib/content/_step-node.yml rename to lib/content/_step-node.yml.handlebars diff --git a/lib/content/_step-test.yml b/lib/content/_step-test.yml.handlebars similarity index 100% rename from lib/content/_step-test.yml rename to lib/content/_step-test.yml.handlebars diff --git a/lib/content/_steps-setup.yml b/lib/content/_steps-setup.yml.handlebars similarity index 100% rename from lib/content/_steps-setup.yml rename to lib/content/_steps-setup.yml.handlebars diff --git a/lib/content/audit.yml b/lib/content/audit.yml.handlebars similarity index 100% rename from lib/content/audit.yml rename to lib/content/audit.yml.handlebars diff --git a/lib/content/bug.yml b/lib/content/bug.yml.handlebars similarity index 100% rename from lib/content/bug.yml rename to lib/content/bug.yml.handlebars diff --git a/lib/content/ci-release.yml b/lib/content/ci-release.yml.handlebars similarity index 100% rename from lib/content/ci-release.yml rename to lib/content/ci-release.yml.handlebars diff --git a/lib/content/ci.yml b/lib/content/ci.yml.handlebars similarity index 100% rename from lib/content/ci.yml rename to lib/content/ci.yml.handlebars diff --git a/lib/content/codeql-analysis.yml b/lib/content/codeql-analysis.yml.handlebars similarity index 100% rename from lib/content/codeql-analysis.yml rename to lib/content/codeql-analysis.yml.handlebars diff --git a/lib/content/commitlintrc.js b/lib/content/commitlintrc.js.handlebars similarity index 100% rename from lib/content/commitlintrc.js rename to lib/content/commitlintrc.js.handlebars diff --git a/lib/content/config.yml b/lib/content/config.yml.handlebars similarity index 100% rename from lib/content/config.yml rename to lib/content/config.yml.handlebars diff --git a/lib/content/dependabot.yml b/lib/content/dependabot.yml.handlebars similarity index 100% rename from lib/content/dependabot.yml rename to lib/content/dependabot.yml.handlebars diff --git a/lib/content/eslintrc.js b/lib/content/eslintrc.js.handlebars similarity index 100% rename from lib/content/eslintrc.js rename to lib/content/eslintrc.js.handlebars diff --git a/lib/content/gitignore b/lib/content/gitignore.handlebars similarity index 100% rename from lib/content/gitignore rename to lib/content/gitignore.handlebars diff --git a/lib/content/index.js b/lib/content/index.js index ed916cc9..f04d8735 100644 --- a/lib/content/index.js +++ b/lib/content/index.js @@ -5,22 +5,22 @@ const isPublic = (p) => p.config.isPublic const sharedRootAdd = (name) => ({ // release '.github/workflows/release.yml': { - file: 'release.yml', + file: 'release.yml.handlebars', filter: isPublic, }, '.github/workflows/ci-release.yml': { - file: 'ci-release.yml', + file: 'ci-release.yml.handlebars', filter: isPublic, }, '.release-please-manifest.json': { - file: 'release-please-manifest.json', + file: 'release-please-manifest.json.handlebars', filter: isPublic, parser: (p) => class extends p.JsonMerge { comment = null }, }, 'release-please-config.json': { - file: 'release-please-config.json', + file: 'release-please-config.json.handlebars', filter: isPublic, parser: (p) => class extends p.JsonMerge { comment = null @@ -28,23 +28,23 @@ const sharedRootAdd = (name) => ({ }, // this lint commits which is only necessary for releases '.github/workflows/pull-request.yml': { - file: 'pull-request.yml', + file: 'pull-request.yml.handlebars', filter: isPublic, }, // ci - '.github/matchers/tap.json': 'tap.json', - [`.github/workflows/ci${name ? `-${name}` : ''}.yml`]: 'ci.yml', + '.github/matchers/tap.json': 'tap.json.handlebars', + [`.github/workflows/ci${name ? `-${name}` : ''}.yml`]: 'ci.yml.handlebars', // dependabot '.github/dependabot.yml': { - file: 'dependabot.yml', + file: 'dependabot.yml.handlebars', filter: (p) => p.config.dependabot, }, '.github/workflows/post-dependabot.yml': { - file: 'post-dependabot.yml', + file: 'post-dependabot.yml.handlebars', filter: (p) => p.config.dependabot, }, '.github/settings.yml': { - file: 'settings.yml', + file: 'settings.yml.handlebars', filter: (p) => !p.config.isReleaseBranch, }, }) @@ -61,12 +61,12 @@ const sharedRootRm = () => ({ // Changes applied to the root of the repo const rootRepo = { add: { - '.commitlintrc.js': 'commitlintrc.js', - '.github/ISSUE_TEMPLATE/bug.yml': 'bug.yml', - '.github/ISSUE_TEMPLATE/config.yml': 'config.yml', - '.github/CODEOWNERS': 'CODEOWNERS', - '.github/workflows/audit.yml': 'audit.yml', - '.github/workflows/codeql-analysis.yml': 'codeql-analysis.yml', + '.commitlintrc.js': 'commitlintrc.js.handlebars', + '.github/ISSUE_TEMPLATE/bug.yml': 'bug.yml.handlebars', + '.github/ISSUE_TEMPLATE/config.yml': 'config.yml.handlebars', + '.github/CODEOWNERS': 'CODEOWNERS.handlebars', + '.github/workflows/audit.yml': 'audit.yml.handlebars', + '.github/workflows/codeql-analysis.yml': 'codeql-analysis.yml.handlebars', ...sharedRootAdd(), }, rm: { @@ -84,15 +84,15 @@ const rootRepo = { const rootModule = { add: { '.eslintrc.js': { - file: 'eslintrc.js', + file: 'eslintrc.js.handlebars', filter: (p) => p.config.eslint, }, - '.gitignore': 'gitignore', - '.npmrc': 'npmrc', - 'SECURITY.md': 'SECURITY.md', - 'CODE_OF_CONDUCT.md': 'CODE_OF_CONDUCT.md', - 'CONTRIBUTING.md': 'CONTRIBUTING.md', - 'package.json': 'pkg.json', + '.gitignore': 'gitignore.handlebars', + '.npmrc': 'npmrc.handlebars', + 'SECURITY.md': 'SECURITY.md.handlebars', + 'CODE_OF_CONDUCT.md': 'CODE_OF_CONDUCT.md.handlebars', + 'CONTRIBUTING.md': 'CONTRIBUTING.md.handlebars', + 'package.json': 'pkg.json.handlebars', }, rm: [ '.eslintrc.!(js|local.*)', @@ -115,11 +115,11 @@ const workspaceRepo = { const workspaceModule = { add: { '.eslintrc.js': { - file: 'eslintrc.js', + file: 'eslintrc.js.handlebars', filter: (p) => p.config.eslint, }, - '.gitignore': 'gitignore', - 'package.json': 'pkg.json', + '.gitignore': 'gitignore.handlebars', + 'package.json': 'pkg.json.handlebars', }, rm: [ '.npmrc', diff --git a/lib/content/npmrc b/lib/content/npmrc.handlebars similarity index 100% rename from lib/content/npmrc rename to lib/content/npmrc.handlebars diff --git a/lib/content/pkg.json b/lib/content/pkg.json.handlebars similarity index 100% rename from lib/content/pkg.json rename to lib/content/pkg.json.handlebars diff --git a/lib/content/post-dependabot.yml b/lib/content/post-dependabot.yml.handlebars similarity index 100% rename from lib/content/post-dependabot.yml rename to lib/content/post-dependabot.yml.handlebars diff --git a/lib/content/pull-request.yml b/lib/content/pull-request.yml.handlebars similarity index 100% rename from lib/content/pull-request.yml rename to lib/content/pull-request.yml.handlebars diff --git a/lib/content/release-please-config.json b/lib/content/release-please-config.json.handlebars similarity index 100% rename from lib/content/release-please-config.json rename to lib/content/release-please-config.json.handlebars diff --git a/lib/content/release-please-manifest.json b/lib/content/release-please-manifest.json.handlebars similarity index 100% rename from lib/content/release-please-manifest.json rename to lib/content/release-please-manifest.json.handlebars diff --git a/lib/content/release.yml b/lib/content/release.yml.handlebars similarity index 100% rename from lib/content/release.yml rename to lib/content/release.yml.handlebars diff --git a/lib/content/settings.yml b/lib/content/settings.yml.handlebars similarity index 100% rename from lib/content/settings.yml rename to lib/content/settings.yml.handlebars diff --git a/lib/content/tap.json b/lib/content/tap.json.handlebars similarity index 100% rename from lib/content/tap.json rename to lib/content/tap.json.handlebars diff --git a/lib/util/template.js b/lib/util/template.js index 1eb67ed7..d42135dd 100644 --- a/lib/util/template.js +++ b/lib/util/template.js @@ -6,7 +6,8 @@ const DELETE = '__DELETE__' const safeValues = (obj) => Object.entries(obj).map(([key, value]) => [key, new Handlebars.SafeString(value)]) -const partialName = (s) => basename(s, extname(s)) // remove extension +const partialName = (s) => basename(s) + .replace(/[.].*/, '') // strip all extensions .replace(/^_/, '') // remove leading underscore .replace(/-([a-z])/g, (_, g) => g.toUpperCase()) // camelcase diff --git a/test/apply/index.js b/test/apply/index.js index a26ea1bf..e4a920bf 100644 --- a/test/apply/index.js +++ b/test/apply/index.js @@ -161,7 +161,7 @@ t.test('workspace config can override root', async (t) => { a: { templateOSS: { workspaceModule: { - add: { '.eslintrc.js': 'eslintrc.js' }, + add: { '.eslintrc.js': 'eslintrc.js.handlebars' }, rm: { '.npmrc': true }, }, }, From f922884c44d37fab1e6be78d9ee2d76d3b513a3c Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 15 Sep 2023 23:41:16 -0500 Subject: [PATCH 2/4] PR feedbaci --- .github/ISSUE_TEMPLATE/config.yml.handlebars | 3 -- .../{CODEOWNERS.handlebars => CODEOWNERS.hbs} | 0 ...T.md.handlebars => CODE_OF_CONDUCT-md.hbs} | 0 ...TING.md.handlebars => CONTRIBUTING-md.hbs} | 0 .../{LICENSE.md.handlebars => LICENSE-md.hbs} | 0 ...SECURITY.md.handlebars => SECURITY-md.hbs} | 0 ...rix.yml.handlebars => _job-matrix-yml.hbs} | 2 +- ...ebars => _job-release-integration-yml.hbs} | 2 +- .../{_job.yml.handlebars => _job-yml.hbs} | 2 +- .../{_on-ci.yml.handlebars => _on-ci-yml.hbs} | 0 ...dit.yml.handlebars => _step-audit-yml.hbs} | 0 ...ks.yml.handlebars => _step-checks-yml.hbs} | 0 ...deps.yml.handlebars => _step-deps-yml.hbs} | 0 ...p-git.yml.handlebars => _step-git-yml.hbs} | 0 ...lint.yml.handlebars => _step-lint-yml.hbs} | 0 ...node.yml.handlebars => _step-node-yml.hbs} | 0 ...test.yml.handlebars => _step-test-yml.hbs} | 0 lib/content/_steps-setup-yml.hbs | 6 +++ lib/content/_steps-setup.yml.handlebars | 6 --- .../{audit.yml.handlebars => audit-yml.hbs} | 4 +- .../{bug.yml.handlebars => bug-yml.hbs} | 0 ...ease.yml.handlebars => ci-release-yml.hbs} | 12 ++--- lib/content/ci-yml.hbs | 13 +++++ lib/content/ci.yml.handlebars | 13 ----- ...yml.handlebars => codeql-analysis-yml.hbs} | 2 +- ...ntrc.js.handlebars => commitlintrc-js.hbs} | 0 .../{config.yml.handlebars => config-yml.hbs} | 0 ...abot.yml.handlebars => dependabot-yml.hbs} | 0 ...eslintrc.js.handlebars => eslintrc-js.hbs} | 0 .../{gitignore.handlebars => gitignore.hbs} | 0 lib/content/index.js | 52 +++++++++---------- lib/content/{npmrc.handlebars => npmrc.hbs} | 0 .../{pkg.json.handlebars => package-json.hbs} | 0 ...yml.handlebars => post-dependabot-yml.hbs} | 2 +- ...st.yml.handlebars => pull-request-yml.hbs} | 2 +- ...dlebars => release-please-config-json.hbs} | 0 ...ebars => release-please-manifest-json.hbs} | 0 ...release.yml.handlebars => release-yml.hbs} | 20 +++---- ...ttings.yml.handlebars => settings-yml.hbs} | 0 .../{tap.json.handlebars => tap-json.hbs} | 0 lib/util/template.js | 3 +- test/apply/index.js | 8 +-- 42 files changed, 74 insertions(+), 78 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/config.yml.handlebars rename lib/content/{CODEOWNERS.handlebars => CODEOWNERS.hbs} (100%) rename lib/content/{CODE_OF_CONDUCT.md.handlebars => CODE_OF_CONDUCT-md.hbs} (100%) rename lib/content/{CONTRIBUTING.md.handlebars => CONTRIBUTING-md.hbs} (100%) rename lib/content/{LICENSE.md.handlebars => LICENSE-md.hbs} (100%) rename lib/content/{SECURITY.md.handlebars => SECURITY-md.hbs} (100%) rename lib/content/{_job-matrix.yml.handlebars => _job-matrix-yml.hbs} (93%) rename lib/content/{_job-release-integration.yml.handlebars => _job-release-integration-yml.hbs} (97%) rename lib/content/{_job.yml.handlebars => _job-yml.hbs} (87%) rename lib/content/{_on-ci.yml.handlebars => _on-ci-yml.hbs} (100%) rename lib/content/{_step-audit.yml.handlebars => _step-audit-yml.hbs} (100%) rename lib/content/{_step-checks.yml.handlebars => _step-checks-yml.hbs} (100%) rename lib/content/{_step-deps.yml.handlebars => _step-deps-yml.hbs} (100%) rename lib/content/{_step-git.yml.handlebars => _step-git-yml.hbs} (100%) rename lib/content/{_step-lint.yml.handlebars => _step-lint-yml.hbs} (100%) rename lib/content/{_step-node.yml.handlebars => _step-node-yml.hbs} (100%) rename lib/content/{_step-test.yml.handlebars => _step-test-yml.hbs} (100%) create mode 100644 lib/content/_steps-setup-yml.hbs delete mode 100644 lib/content/_steps-setup.yml.handlebars rename lib/content/{audit.yml.handlebars => audit-yml.hbs} (61%) rename lib/content/{bug.yml.handlebars => bug-yml.hbs} (100%) rename lib/content/{ci-release.yml.handlebars => ci-release-yml.hbs} (73%) create mode 100644 lib/content/ci-yml.hbs delete mode 100644 lib/content/ci.yml.handlebars rename lib/content/{codeql-analysis.yml.handlebars => codeql-analysis-yml.hbs} (96%) rename lib/content/{commitlintrc.js.handlebars => commitlintrc-js.hbs} (100%) rename lib/content/{config.yml.handlebars => config-yml.hbs} (100%) rename lib/content/{dependabot.yml.handlebars => dependabot-yml.hbs} (100%) rename lib/content/{eslintrc.js.handlebars => eslintrc-js.hbs} (100%) rename lib/content/{gitignore.handlebars => gitignore.hbs} (100%) rename lib/content/{npmrc.handlebars => npmrc.hbs} (100%) rename lib/content/{pkg.json.handlebars => package-json.hbs} (100%) rename lib/content/{post-dependabot.yml.handlebars => post-dependabot-yml.hbs} (99%) rename lib/content/{pull-request.yml.handlebars => pull-request-yml.hbs} (89%) rename lib/content/{release-please-config.json.handlebars => release-please-config-json.hbs} (100%) rename lib/content/{release-please-manifest.json.handlebars => release-please-manifest-json.hbs} (100%) rename lib/content/{release.yml.handlebars => release-yml.hbs} (90%) rename lib/content/{settings.yml.handlebars => settings-yml.hbs} (100%) rename lib/content/{tap.json.handlebars => tap-json.hbs} (100%) diff --git a/.github/ISSUE_TEMPLATE/config.yml.handlebars b/.github/ISSUE_TEMPLATE/config.yml.handlebars deleted file mode 100644 index 571fd5ff..00000000 --- a/.github/ISSUE_TEMPLATE/config.yml.handlebars +++ /dev/null @@ -1,3 +0,0 @@ -This file is automatically added by @npmcli/template-oss. Do not edit. - -blank_issues_enabled: true diff --git a/lib/content/CODEOWNERS.handlebars b/lib/content/CODEOWNERS.hbs similarity index 100% rename from lib/content/CODEOWNERS.handlebars rename to lib/content/CODEOWNERS.hbs diff --git a/lib/content/CODE_OF_CONDUCT.md.handlebars b/lib/content/CODE_OF_CONDUCT-md.hbs similarity index 100% rename from lib/content/CODE_OF_CONDUCT.md.handlebars rename to lib/content/CODE_OF_CONDUCT-md.hbs diff --git a/lib/content/CONTRIBUTING.md.handlebars b/lib/content/CONTRIBUTING-md.hbs similarity index 100% rename from lib/content/CONTRIBUTING.md.handlebars rename to lib/content/CONTRIBUTING-md.hbs diff --git a/lib/content/LICENSE.md.handlebars b/lib/content/LICENSE-md.hbs similarity index 100% rename from lib/content/LICENSE.md.handlebars rename to lib/content/LICENSE-md.hbs diff --git a/lib/content/SECURITY.md.handlebars b/lib/content/SECURITY-md.hbs similarity index 100% rename from lib/content/SECURITY.md.handlebars rename to lib/content/SECURITY-md.hbs diff --git a/lib/content/_job-matrix.yml.handlebars b/lib/content/_job-matrix-yml.hbs similarity index 93% rename from lib/content/_job-matrix.yml.handlebars rename to lib/content/_job-matrix-yml.hbs index 8d77a5c2..5ad768b0 100644 --- a/lib/content/_job-matrix.yml.handlebars +++ b/lib/content/_job-matrix-yml.hbs @@ -26,4 +26,4 @@ defaults: run: shell: $\{{ matrix.platform.shell }} steps: - {{> stepsSetup jobIsMatrix=true }} + {{> stepsSetupYml jobIsMatrix=true }} diff --git a/lib/content/_job-release-integration.yml.handlebars b/lib/content/_job-release-integration-yml.hbs similarity index 97% rename from lib/content/_job-release-integration.yml.handlebars rename to lib/content/_job-release-integration-yml.hbs index 136ca0a1..2cd8787f 100644 --- a/lib/content/_job-release-integration.yml.handlebars +++ b/lib/content/_job-release-integration-yml.hbs @@ -29,7 +29,7 @@ defaults: run: shell: bash steps: - {{> stepNode lockfile=false }} + {{> stepNodeYml lockfile=false }} - name: View in Registry run: | EXIT_CODE=0 diff --git a/lib/content/_job.yml.handlebars b/lib/content/_job-yml.hbs similarity index 87% rename from lib/content/_job.yml.handlebars rename to lib/content/_job-yml.hbs index 48c6100a..4dab1885 100644 --- a/lib/content/_job.yml.handlebars +++ b/lib/content/_job-yml.hbs @@ -5,4 +5,4 @@ defaults: run: shell: bash steps: - {{> stepsSetup }} + {{> stepsSetupYml }} diff --git a/lib/content/_on-ci.yml.handlebars b/lib/content/_on-ci-yml.hbs similarity index 100% rename from lib/content/_on-ci.yml.handlebars rename to lib/content/_on-ci-yml.hbs diff --git a/lib/content/_step-audit.yml.handlebars b/lib/content/_step-audit-yml.hbs similarity index 100% rename from lib/content/_step-audit.yml.handlebars rename to lib/content/_step-audit-yml.hbs diff --git a/lib/content/_step-checks.yml.handlebars b/lib/content/_step-checks-yml.hbs similarity index 100% rename from lib/content/_step-checks.yml.handlebars rename to lib/content/_step-checks-yml.hbs diff --git a/lib/content/_step-deps.yml.handlebars b/lib/content/_step-deps-yml.hbs similarity index 100% rename from lib/content/_step-deps.yml.handlebars rename to lib/content/_step-deps-yml.hbs diff --git a/lib/content/_step-git.yml.handlebars b/lib/content/_step-git-yml.hbs similarity index 100% rename from lib/content/_step-git.yml.handlebars rename to lib/content/_step-git-yml.hbs diff --git a/lib/content/_step-lint.yml.handlebars b/lib/content/_step-lint-yml.hbs similarity index 100% rename from lib/content/_step-lint.yml.handlebars rename to lib/content/_step-lint-yml.hbs diff --git a/lib/content/_step-node.yml.handlebars b/lib/content/_step-node-yml.hbs similarity index 100% rename from lib/content/_step-node.yml.handlebars rename to lib/content/_step-node-yml.hbs diff --git a/lib/content/_step-test.yml.handlebars b/lib/content/_step-test-yml.hbs similarity index 100% rename from lib/content/_step-test.yml.handlebars rename to lib/content/_step-test-yml.hbs diff --git a/lib/content/_steps-setup-yml.hbs b/lib/content/_steps-setup-yml.hbs new file mode 100644 index 00000000..962f2885 --- /dev/null +++ b/lib/content/_steps-setup-yml.hbs @@ -0,0 +1,6 @@ +{{~#if jobCheck}}{{> stepChecksYml }}{{/if}} +{{~#unless jobSkipSetup}} +{{> stepGitYml }} +{{> stepNodeYml }} +{{> stepDepsYml }} +{{/unless}} diff --git a/lib/content/_steps-setup.yml.handlebars b/lib/content/_steps-setup.yml.handlebars deleted file mode 100644 index e17d5f3d..00000000 --- a/lib/content/_steps-setup.yml.handlebars +++ /dev/null @@ -1,6 +0,0 @@ -{{~#if jobCheck}}{{> stepChecks }}{{/if}} -{{~#unless jobSkipSetup}} -{{> stepGit }} -{{> stepNode }} -{{> stepDeps }} -{{/unless}} diff --git a/lib/content/audit.yml.handlebars b/lib/content/audit-yml.hbs similarity index 61% rename from lib/content/audit.yml.handlebars rename to lib/content/audit-yml.hbs index 77ef4b89..07794faa 100644 --- a/lib/content/audit.yml.handlebars +++ b/lib/content/audit-yml.hbs @@ -8,5 +8,5 @@ on: jobs: audit: - {{> job jobName="Audit Dependencies" jobDepFlags="--package-lock" }} - {{> stepAudit }} + {{> jobYml jobName="Audit Dependencies" jobDepFlags="--package-lock" }} + {{> stepAuditYml }} diff --git a/lib/content/bug.yml.handlebars b/lib/content/bug-yml.hbs similarity index 100% rename from lib/content/bug.yml.handlebars rename to lib/content/bug-yml.hbs diff --git a/lib/content/ci-release.yml.handlebars b/lib/content/ci-release-yml.hbs similarity index 73% rename from lib/content/ci-release.yml.handlebars rename to lib/content/ci-release-yml.hbs index 73bb97b8..6253ffe9 100644 --- a/lib/content/ci-release.yml.handlebars +++ b/lib/content/ci-release-yml.hbs @@ -19,19 +19,19 @@ on: jobs: lint-all: - {{> job + {{> jobYml jobName="Lint All" jobCheck=(obj sha="inputs.check-sha") jobCheckout=(obj ref="${{ inputs.ref }}") }} - {{> stepLint jobRunFlags=allFlags }} - {{> stepChecks jobCheck=true }} + {{> stepLintYml jobRunFlags=allFlags }} + {{> stepChecksYml jobCheck=true }} test-all: - {{> jobMatrix + {{> jobMatrixYml jobName="Test All" jobCheck=(obj sha="inputs.check-sha") jobCheckout=(obj ref="${{ inputs.ref }}") }} - {{> stepTest jobRunFlags=allFlags }} - {{> stepChecks jobCheck=true }} + {{> stepTestYml jobRunFlags=allFlags }} + {{> stepChecksYml jobCheck=true }} diff --git a/lib/content/ci-yml.hbs b/lib/content/ci-yml.hbs new file mode 100644 index 00000000..ebb6d917 --- /dev/null +++ b/lib/content/ci-yml.hbs @@ -0,0 +1,13 @@ +name: CI {{~#if isWorkspace}} - {{ pkgName }}{{/if}} + +on: + {{> onCiYml }} + +jobs: + lint: + {{> jobYml jobName="Lint" }} + {{> stepLintYml jobRunFlags=pkgFlags }} + + test: + {{> jobMatrixYml jobName="Test" }} + {{> stepTestYml jobRunFlags=pkgFlags }} diff --git a/lib/content/ci.yml.handlebars b/lib/content/ci.yml.handlebars deleted file mode 100644 index 0226d0c3..00000000 --- a/lib/content/ci.yml.handlebars +++ /dev/null @@ -1,13 +0,0 @@ -name: CI {{~#if isWorkspace}} - {{ pkgName }}{{/if}} - -on: - {{> onCi }} - -jobs: - lint: - {{> job jobName="Lint" }} - {{> stepLint jobRunFlags=pkgFlags }} - - test: - {{> jobMatrix jobName="Test" }} - {{> stepTest jobRunFlags=pkgFlags }} diff --git a/lib/content/codeql-analysis.yml.handlebars b/lib/content/codeql-analysis-yml.hbs similarity index 96% rename from lib/content/codeql-analysis.yml.handlebars rename to lib/content/codeql-analysis-yml.hbs index 4903a0be..78415d3f 100644 --- a/lib/content/codeql-analysis.yml.handlebars +++ b/lib/content/codeql-analysis-yml.hbs @@ -24,7 +24,7 @@ jobs: contents: read security-events: write steps: - {{> stepGit }} + {{> stepGitYml }} - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/lib/content/commitlintrc.js.handlebars b/lib/content/commitlintrc-js.hbs similarity index 100% rename from lib/content/commitlintrc.js.handlebars rename to lib/content/commitlintrc-js.hbs diff --git a/lib/content/config.yml.handlebars b/lib/content/config-yml.hbs similarity index 100% rename from lib/content/config.yml.handlebars rename to lib/content/config-yml.hbs diff --git a/lib/content/dependabot.yml.handlebars b/lib/content/dependabot-yml.hbs similarity index 100% rename from lib/content/dependabot.yml.handlebars rename to lib/content/dependabot-yml.hbs diff --git a/lib/content/eslintrc.js.handlebars b/lib/content/eslintrc-js.hbs similarity index 100% rename from lib/content/eslintrc.js.handlebars rename to lib/content/eslintrc-js.hbs diff --git a/lib/content/gitignore.handlebars b/lib/content/gitignore.hbs similarity index 100% rename from lib/content/gitignore.handlebars rename to lib/content/gitignore.hbs diff --git a/lib/content/index.js b/lib/content/index.js index f04d8735..bccb3711 100644 --- a/lib/content/index.js +++ b/lib/content/index.js @@ -5,22 +5,22 @@ const isPublic = (p) => p.config.isPublic const sharedRootAdd = (name) => ({ // release '.github/workflows/release.yml': { - file: 'release.yml.handlebars', + file: 'release-yml.hbs', filter: isPublic, }, '.github/workflows/ci-release.yml': { - file: 'ci-release.yml.handlebars', + file: 'ci-release-yml.hbs', filter: isPublic, }, '.release-please-manifest.json': { - file: 'release-please-manifest.json.handlebars', + file: 'release-please-manifest-json.hbs', filter: isPublic, parser: (p) => class extends p.JsonMerge { comment = null }, }, 'release-please-config.json': { - file: 'release-please-config.json.handlebars', + file: 'release-please-config-json.hbs', filter: isPublic, parser: (p) => class extends p.JsonMerge { comment = null @@ -28,23 +28,23 @@ const sharedRootAdd = (name) => ({ }, // this lint commits which is only necessary for releases '.github/workflows/pull-request.yml': { - file: 'pull-request.yml.handlebars', + file: 'pull-request-yml.hbs', filter: isPublic, }, // ci - '.github/matchers/tap.json': 'tap.json.handlebars', - [`.github/workflows/ci${name ? `-${name}` : ''}.yml`]: 'ci.yml.handlebars', + '.github/matchers/tap.json': 'tap-json.hbs', + [`.github/workflows/ci${name ? `-${name}` : ''}.yml`]: 'ci-yml.hbs', // dependabot '.github/dependabot.yml': { - file: 'dependabot.yml.handlebars', + file: 'dependabot-yml.hbs', filter: (p) => p.config.dependabot, }, '.github/workflows/post-dependabot.yml': { - file: 'post-dependabot.yml.handlebars', + file: 'post-dependabot-yml.hbs', filter: (p) => p.config.dependabot, }, '.github/settings.yml': { - file: 'settings.yml.handlebars', + file: 'settings-yml.hbs', filter: (p) => !p.config.isReleaseBranch, }, }) @@ -61,12 +61,12 @@ const sharedRootRm = () => ({ // Changes applied to the root of the repo const rootRepo = { add: { - '.commitlintrc.js': 'commitlintrc.js.handlebars', - '.github/ISSUE_TEMPLATE/bug.yml': 'bug.yml.handlebars', - '.github/ISSUE_TEMPLATE/config.yml': 'config.yml.handlebars', - '.github/CODEOWNERS': 'CODEOWNERS.handlebars', - '.github/workflows/audit.yml': 'audit.yml.handlebars', - '.github/workflows/codeql-analysis.yml': 'codeql-analysis.yml.handlebars', + '.commitlintrc.js': 'commitlintrc-js.hbs', + '.github/ISSUE_TEMPLATE/bug.yml': 'bug-yml.hbs', + '.github/ISSUE_TEMPLATE/config.yml': 'config-yml.hbs', + '.github/CODEOWNERS': 'CODEOWNERS.hbs', + '.github/workflows/audit.yml': 'audit-yml.hbs', + '.github/workflows/codeql-analysis.yml': 'codeql-analysis-yml.hbs', ...sharedRootAdd(), }, rm: { @@ -84,15 +84,15 @@ const rootRepo = { const rootModule = { add: { '.eslintrc.js': { - file: 'eslintrc.js.handlebars', + file: 'eslintrc-js.hbs', filter: (p) => p.config.eslint, }, - '.gitignore': 'gitignore.handlebars', - '.npmrc': 'npmrc.handlebars', - 'SECURITY.md': 'SECURITY.md.handlebars', - 'CODE_OF_CONDUCT.md': 'CODE_OF_CONDUCT.md.handlebars', - 'CONTRIBUTING.md': 'CONTRIBUTING.md.handlebars', - 'package.json': 'pkg.json.handlebars', + '.gitignore': 'gitignore.hbs', + '.npmrc': 'npmrc.hbs', + 'SECURITY.md': 'SECURITY-md.hbs', + 'CODE_OF_CONDUCT.md': 'CODE_OF_CONDUCT-md.hbs', + 'CONTRIBUTING.md': 'CONTRIBUTING-md.hbs', + 'package.json': 'package-json.hbs', }, rm: [ '.eslintrc.!(js|local.*)', @@ -115,11 +115,11 @@ const workspaceRepo = { const workspaceModule = { add: { '.eslintrc.js': { - file: 'eslintrc.js.handlebars', + file: 'eslintrc-js.hbs', filter: (p) => p.config.eslint, }, - '.gitignore': 'gitignore.handlebars', - 'package.json': 'pkg.json.handlebars', + '.gitignore': 'gitignore.hbs', + 'package.json': 'package-json.hbs', }, rm: [ '.npmrc', diff --git a/lib/content/npmrc.handlebars b/lib/content/npmrc.hbs similarity index 100% rename from lib/content/npmrc.handlebars rename to lib/content/npmrc.hbs diff --git a/lib/content/pkg.json.handlebars b/lib/content/package-json.hbs similarity index 100% rename from lib/content/pkg.json.handlebars rename to lib/content/package-json.hbs diff --git a/lib/content/post-dependabot.yml.handlebars b/lib/content/post-dependabot-yml.hbs similarity index 99% rename from lib/content/post-dependabot.yml.handlebars rename to lib/content/post-dependabot-yml.hbs index fe7526c4..46cfdc58 100644 --- a/lib/content/post-dependabot.yml.handlebars +++ b/lib/content/post-dependabot-yml.hbs @@ -8,7 +8,7 @@ permissions: jobs: template-oss: - {{> job + {{> jobYml jobName="template-oss" jobIf="github.actor == 'dependabot[bot]'" jobCheckout=(obj ref="${{ github.event.pull_request.head.ref }}") diff --git a/lib/content/pull-request.yml.handlebars b/lib/content/pull-request-yml.hbs similarity index 89% rename from lib/content/pull-request.yml.handlebars rename to lib/content/pull-request-yml.hbs index 3c523b71..a4db6afe 100644 --- a/lib/content/pull-request.yml.handlebars +++ b/lib/content/pull-request-yml.hbs @@ -10,7 +10,7 @@ on: jobs: commitlint: - {{> job jobName="Lint Commits" jobCheckout=(obj fetch-depth=0) }} + {{> jobYml jobName="Lint Commits" jobCheckout=(obj fetch-depth=0) }} - name: Run Commitlint on Commits id: commit continue-on-error: true diff --git a/lib/content/release-please-config.json.handlebars b/lib/content/release-please-config-json.hbs similarity index 100% rename from lib/content/release-please-config.json.handlebars rename to lib/content/release-please-config-json.hbs diff --git a/lib/content/release-please-manifest.json.handlebars b/lib/content/release-please-manifest-json.hbs similarity index 100% rename from lib/content/release-please-manifest.json.handlebars rename to lib/content/release-please-manifest-json.hbs diff --git a/lib/content/release.yml.handlebars b/lib/content/release-yml.hbs similarity index 90% rename from lib/content/release.yml.handlebars rename to lib/content/release-yml.hbs index 976e1e90..43e7acbc 100644 --- a/lib/content/release.yml.handlebars +++ b/lib/content/release-yml.hbs @@ -27,7 +27,7 @@ jobs: pr-number: $\{{ steps.release.outputs.pr-number }} comment-id: $\{{ steps.pr-comment.outputs.result }} check-id: $\{{ steps.check.outputs.check_id }} - {{> job jobName="Release" }} + {{> jobYml jobName="Release" }} - name: Release Please id: release env: @@ -66,14 +66,14 @@ jobs: } return commentId - {{> stepChecks jobCheck=(obj name="Release" sha="steps.release.outputs.pr-sha") }} + {{> stepChecksYml jobCheck=(obj name="Release" sha="steps.release.outputs.pr-sha") }} update: needs: release outputs: sha: $\{{ steps.commit.outputs.sha }} check-id: $\{{ steps.check.outputs.check_id }} - {{> job + {{> jobYml jobName="Update - Release" jobIf="needs.release.outputs.pr" jobCheckout=(obj ref="${{ needs.release.outputs.branch }}" fetch-depth=0) @@ -94,8 +94,8 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - {{> stepChecks jobName="Update - Release" jobCheck=(obj sha="steps.commit.outputs.sha" name="Release" )}} - {{> stepChecks jobCheck=(obj id="needs.release.outputs.check-id" )}} + {{> stepChecksYml jobName="Update - Release" jobCheck=(obj sha="steps.commit.outputs.sha" name="Release" )}} + {{> stepChecksYml jobCheck=(obj id="needs.release.outputs.check-id" )}} ci: name: CI - Release @@ -108,7 +108,7 @@ jobs: post-ci: needs: [release, update, ci] - {{> job jobName="Post CI - Release" jobIf="needs.release.outputs.pr && always()" jobSkipSetup=true }} + {{> jobYml jobName="Post CI - Release" jobIf="needs.release.outputs.pr && always()" jobSkipSetup=true }} - name: Get Needs Result id: needs-result run: | @@ -121,11 +121,11 @@ jobs: result="success" fi echo "result=$result" >> $GITHUB_OUTPUT - {{> stepChecks jobCheck=(obj id="needs.update.outputs.check-id" status="steps.needs-result.outputs.result") }} + {{> stepChecksYml jobCheck=(obj id="needs.update.outputs.check-id" status="steps.needs-result.outputs.result") }} post-release: needs: release - {{> job jobName="Post Release - Release" jobIf="needs.release.outputs.releases" jobSkipSetup=true }} + {{> jobYml jobName="Post Release - Release" jobIf="needs.release.outputs.releases" jobSkipSetup=true }} - name: Create Release PR Comment uses: actions/github-script@v6 env: @@ -163,11 +163,11 @@ jobs: needs: release name: Release Integration if: needs.release.outputs.release - {{> jobReleaseIntegration }} + {{> jobReleaseIntegrationYml }} post-release-integration: needs: [release, release-integration] - {{> job jobName="Post Release Integration - Release" jobIf="needs.release.outputs.release && always()" jobSkipSetup=true }} + {{> jobYml jobName="Post Release Integration - Release" jobIf="needs.release.outputs.release && always()" jobSkipSetup=true }} - name: Get Needs Result id: needs-result run: | diff --git a/lib/content/settings.yml.handlebars b/lib/content/settings-yml.hbs similarity index 100% rename from lib/content/settings.yml.handlebars rename to lib/content/settings-yml.hbs diff --git a/lib/content/tap.json.handlebars b/lib/content/tap-json.hbs similarity index 100% rename from lib/content/tap.json.handlebars rename to lib/content/tap-json.hbs diff --git a/lib/util/template.js b/lib/util/template.js index d42135dd..1eb67ed7 100644 --- a/lib/util/template.js +++ b/lib/util/template.js @@ -6,8 +6,7 @@ const DELETE = '__DELETE__' const safeValues = (obj) => Object.entries(obj).map(([key, value]) => [key, new Handlebars.SafeString(value)]) -const partialName = (s) => basename(s) - .replace(/[.].*/, '') // strip all extensions +const partialName = (s) => basename(s, extname(s)) // remove extension .replace(/^_/, '') // remove leading underscore .replace(/-([a-z])/g, (_, g) => g.toUpperCase()) // camelcase diff --git a/test/apply/index.js b/test/apply/index.js index e4a920bf..8e10f3fd 100644 --- a/test/apply/index.js +++ b/test/apply/index.js @@ -161,7 +161,7 @@ t.test('workspace config can override root', async (t) => { a: { templateOSS: { workspaceModule: { - add: { '.eslintrc.js': 'eslintrc.js.handlebars' }, + add: { '.eslintrc.js': 'eslintrc-js.hbs' }, rm: { '.npmrc': true }, }, }, @@ -224,9 +224,9 @@ t.test('content can override partials', async (t) => { add:{'.github/workflows/ci-release.yml': 'ci-release.yml'} } }`, - 'ci-release.yml': '{{> ciRelease }}\n job: 1', + 'ci-release.yml': '{{> ciReleaseYml }}\n job: 1', '_step-deps.yml': '- run: INSTALL\n', - '_step-test.yml': '- run: TEST\n{{> defaultStepTest }}\n', + '_step-test.yml': '- run: TEST\n{{> defaultStepTestYml }}\n', }, }, }) @@ -251,7 +251,7 @@ t.test('content can extend files', async (t) => { content_dir: { // eslint-disable-next-line max-len 'index.js': 'module.exports={rootRepo:{add:{".github/workflows/release.yml": "release.yml"}}}', - 'release.yml': '{{> ciRelease}}\n smoke-publish:\n runs-on: ubuntu-latest', + 'release.yml': '{{> ciReleaseYml}}\n smoke-publish:\n runs-on: ubuntu-latest', }, }, }) From 5d5827d02887ec5301c91bb217e2387df00d4b25 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 16 Sep 2023 00:08:01 -0500 Subject: [PATCH 3/4] Fix up tests --- test/apply/allow-paths.js | 4 ++-- test/apply/index.js | 16 ++++++++-------- test/setup.js | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/apply/allow-paths.js b/test/apply/allow-paths.js index 2cf93fd1..fd272d68 100644 --- a/test/apply/allow-paths.js +++ b/test/apply/allow-paths.js @@ -34,8 +34,8 @@ t.test('works with custom content', async (t) => { }, testdir: { content_dir: { - 'paths.json': '{{{json allowPaths}}}', - 'index.js': 'module.exports={rootRepo:{add:{"paths.json":"paths.json"}}}', + 'paths-json.hbs': '{{{json allowPaths}}}', + 'index.js': 'module.exports={rootRepo:{add:{"paths.json":"paths-json.hbs"}}}', }, }, }) diff --git a/test/apply/index.js b/test/apply/index.js index 8e10f3fd..f813b36a 100644 --- a/test/apply/index.js +++ b/test/apply/index.js @@ -199,8 +199,8 @@ t.test('workspaces can override content', async (t) => { testdir: { content_dir: { 'index.js': 'module.exports={}' }, content_dir2: { - 'x.js': 'exists', - 'index.js': 'module.exports={workspaceRepo:{add:{"x.js":"x.js"}}}', + 'x-js.hbs': 'exists', + 'index.js': 'module.exports={workspaceRepo:{add:{"x.js":"x-js.hbs"}}}', }, }, }) @@ -221,12 +221,12 @@ t.test('content can override partials', async (t) => { content_dir: { 'index.js': `module.exports={ rootRepo:{ - add:{'.github/workflows/ci-release.yml': 'ci-release.yml'} + add:{'.github/workflows/ci-release.yml': 'ci-release-yml.hbs'} } }`, - 'ci-release.yml': '{{> ciReleaseYml }}\n job: 1', - '_step-deps.yml': '- run: INSTALL\n', - '_step-test.yml': '- run: TEST\n{{> defaultStepTestYml }}\n', + 'ci-release-yml.hbs': '{{> ciReleaseYml }}\n job: 1', + '_step-deps-yml.hbs': '- run: INSTALL\n', + '_step-test-yml.hbs': '- run: TEST\n{{> defaultStepTestYml }}\n', }, }, }) @@ -250,8 +250,8 @@ t.test('content can extend files', async (t) => { testdir: { content_dir: { // eslint-disable-next-line max-len - 'index.js': 'module.exports={rootRepo:{add:{".github/workflows/release.yml": "release.yml"}}}', - 'release.yml': '{{> ciReleaseYml}}\n smoke-publish:\n runs-on: ubuntu-latest', + 'index.js': 'module.exports={rootRepo:{add:{".github/workflows/release.yml": "release-yml.hbs"}}}', + 'release-yml.hbs': '{{> ciReleaseYml}}\n smoke-publish:\n runs-on: ubuntu-latest', }, }, }) diff --git a/test/setup.js b/test/setup.js index 32c817de..2f9f8387 100644 --- a/test/setup.js +++ b/test/setup.js @@ -106,7 +106,7 @@ const setup = async (t, { workspaces = {}, testdir = {}, mocks = {}, - ok, + ok = false, } = {}) => { const wsLookup = {} const pkg = merge( From 69e83a15bf09dc0ded7040390f4d30ec2b8b4f84 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 16 Sep 2023 00:55:01 -0500 Subject: [PATCH 4/4] Freshen up readme --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1a423510..18bf24af 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This module bundles the npm CLI team's basics for package development into a single devDependency. -**CAUTION: THESE CHANGES WILL OVERWRITE ANY LOCAL FILES AND SETTINGS** +**CAUTION: THESE CHANGES WILL OVERWRITE LOCAL FILES AND SETTINGS** ### Configuration @@ -60,21 +60,21 @@ any of the same settings in the root. ### Content All the templated content for this repo lives in -[`lib/content/`](./lib/content/). The `index.js`[./lib/content/index.js] file +[`lib/content/`](./lib/content/). The [`index.js`](./lib/content/index.js) file controls how and where this content is written. Content files can be overwritten or merged with the existing target file. -Currently mergining is only supported for `package.json` files. +Merging is only supported for some types of files (ini, yaml, json, package.json) Each content file goes through the following pipeline: 1. It is read from its source location -1. It is are templated using Handlebars with the variables from each packages's - config (with some derived values generated in [`config.js`](./lib/config.js) -1. It is parsed based on its file extension in +2. It is compiled using [Handlebars](https://handlebarsjs.com/) with the variables from each packages's + config (with some derived values generated in [`config.js`](./lib/config.js)) +3. It is parsed based on its file extension in [`parser.js`](./lib/util/parser.js) -1. Additional logic is applied by the parser -1. It is written to its target location +4. Additional logic is applied by the parser +5. It is written to its target location ### Usage @@ -82,7 +82,7 @@ This package provides two bin scripts: #### `template-oss-check` -This will check if any of the applied files different from the target content, +This will check if any of the applied files differ from the target content, or if any of the other associated checks fail. The diffs of each file or check will be reported with instructions on how to fix it. @@ -92,7 +92,7 @@ This will write all source files to their target locations in the cwd. It will do nothing if `package.json#templateOSS.version` is the same as the version being run. This can be overridden by `--force`. -This is the script that is run on `postinsall`. +This is the script that is run on `postinstall`. ### Extending @@ -100,7 +100,7 @@ This is the script that is run on `postinsall`. This directory is where all the logic for applying files lives. It should be possible to add new files without modifying anything in this directory. To add a -file, add the templated file to `lib/content/$FILENAME` and add entry for it in +file, add the templated file to `lib/content/$FILENAME` and an entry for it in `lib/content/index.js` depending on where and when it should be written (root vs workspace, repo vs module, add vs remove, etc).