-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathsource-snapshots.js.test.cjs
4661 lines (4291 loc) · 139 KB
/
source-snapshots.js.test.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/apply/source-snapshots.js TAP root only > expect resolving Promise 1`] = `
.commitlintrc.js
========================================
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0],
'body-max-line-length': [0],
},
}
.eslintrc.js
========================================
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => \`./\${file}\`)
module.exports = {
root: true,
ignorePatterns: [
'tap-testdir*/',
],
extends: [
'@npmcli',
...localConfigs,
],
}
.github/actions/create-check/action.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Create Check'
inputs:
name:
required: true
token:
required: true
sha:
required: true
check-name:
default: ''
outputs:
check-id:
value: \${{ steps.create-check.outputs.check_id }}
runs:
using: "composite"
steps:
- name: Get Workflow Job
uses: actions/github-script@v7
id: workflow
env:
JOB_NAME: "\${{ inputs.name }}"
SHA: "\${{ inputs.sha }}"
with:
result-encoding: string
script: |
const { repo: { owner, repo}, runId, serverUrl } = context
const { JOB_NAME, SHA } = process.env
const job = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId,
per_page: 100
}).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME)))
return [
\`This check is assosciated with \${serverUrl}/\${owner}/\${repo}/commit/\${SHA}.\`,
'Run logs:',
job?.html_url || \`could not be found for a job ending with: "\${JOB_NAME}"\`,
].join(' ')
- name: Create Check
uses: LouisBrunner/[email protected]
id: create-check
with:
token: \${{ inputs.token }}
sha: \${{ inputs.sha }}
status: in_progress
name: \${{ inputs.check-name || inputs.name }}
output: |
{"summary":"\${{ steps.workflow.outputs.result }}"}
.github/actions/install-latest-npm/action.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Install Latest npm'
description: 'Install the latest version of npm compatible with the Node version'
inputs:
node:
description: 'Current Node version'
required: true
runs:
using: "composite"
steps:
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
runner.os == 'Windows' && (
startsWith(inputs.node, 'v10.') ||
startsWith(inputs.node, 'v12.') ||
startsWith(inputs.node, 'v14.')
)
shell: cmd
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install Latest npm
shell: bash
env:
NODE_VERSION: \${{ inputs.node }}
working-directory: \${{ runner.temp }}
run: |
MATCH=""
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
echo "node@$NODE_VERSION"
for SPEC in \${SPECS[@]}; do
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
MATCH=$SPEC
echo "Found compatible version: npm@$MATCH"
break
fi
done
if [ -z $MATCH ]; then
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
exit 1
fi
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
- name: npm Version
shell: bash
run: npm -v
.github/CODEOWNERS
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
.github/dependabot.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
target-branch: "main"
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
open-pull-requests-limit: 10
- package-ecosystem: npm
directory: /
schedule:
interval: daily
target-branch: "latest"
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
open-pull-requests-limit: 10
.github/ISSUE_TEMPLATE/bug.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
.github/ISSUE_TEMPLATE/config.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
.github/matchers/tap.json
========================================
{
"//@npmcli/template-oss": "This file is automatically added by @npmcli/template-oss. Do not edit.",
"problemMatcher": [
{
"owner": "tap",
"pattern": [
{
"regexp": "^/s*not ok /d+ - (.*)",
"message": 1
},
{
"regexp": "^/s*---"
},
{
"regexp": "^/s*at:"
},
{
"regexp": "^/s*line:/s*(/d+)",
"line": 1
},
{
"regexp": "^/s*column:/s*(/d+)",
"column": 1
},
{
"regexp": "^/s*file:/s*(.*)",
"file": 1
}
]
}
]
}
.github/settings.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
repository:
allow_merge_commit: false
allow_rebase_merge: true
allow_squash_merge: true
squash_merge_commit_title: PR_TITLE
squash_merge_commit_message: PR_BODY
delete_branch_on_merge: true
enable_automated_security_fixes: true
enable_vulnerability_alerts: true
branches:
- name: main
protection:
required_status_checks: null
enforce_admins: true
block_creations: true
required_pull_request_reviews:
required_approving_review_count: 1
require_code_owner_reviews: true
require_last_push_approval: true
dismiss_stale_reviews: true
restrictions:
apps: []
users: []
teams: [ "cli-team" ]
- name: latest
protection:
required_status_checks: null
enforce_admins: true
block_creations: true
required_pull_request_reviews:
required_approving_review_count: 1
require_code_owner_reviews: true
require_last_push_approval: true
dismiss_stale_reviews: true
restrictions:
apps: []
users: []
teams: [ "cli-team" ]
.github/workflows/audit.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Audit
on:
workflow_dispatch:
schedule:
# "At 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
- cron: "0 8 * * 1"
jobs:
audit:
name: Audit Dependencies
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
run: npm audit --omit=dev
- name: Run Full Audit
run: npm audit --audit-level=none
.github/workflows/ci-release.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI - Release
on:
workflow_dispatch:
inputs:
ref:
required: true
type: string
default: main
workflow_call:
inputs:
ref:
required: true
type: string
check-sha:
required: true
type: string
jobs:
lint-all:
name: Lint All
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: \${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Create Check
id: create-check
if: \${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Lint All"
token: \${{ secrets.GITHUB_TOKEN }}
sha: \${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/[email protected]
if: always()
with:
token: \${{ secrets.GITHUB_TOKEN }}
conclusion: \${{ job.status }}
check_id: \${{ steps.create-check.outputs.check-id }}
test-all:
name: Test All - \${{ matrix.platform.name }} - \${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: macOS
os: macos-13
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 22.x
exclude:
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 22.x
runs-on: \${{ matrix.platform.os }}
defaults:
run:
shell: \${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: \${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Create Check
id: create-check
if: \${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Test All - \${{ matrix.platform.name }} - \${{ matrix.node-version }}"
token: \${{ secrets.GITHUB_TOKEN }}
sha: \${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/[email protected]
if: always()
with:
token: \${{ secrets.GITHUB_TOKEN }}
conclusion: \${{ job.status }}
check_id: \${{ steps.create-check.outputs.check-id }}
.github/workflows/ci.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- latest
- release/v*
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
jobs:
lint:
name: Lint
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
test:
name: Test - \${{ matrix.platform.name }} - \${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: macOS
os: macos-13
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 22.x
exclude:
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 22.x
runs-on: \${{ matrix.platform.os }}
defaults:
run:
shell: \${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
.github/workflows/codeql-analysis.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: CodeQL
on:
push:
branches:
- main
- latest
- release/v*
pull_request:
branches:
- main
- latest
- release/v*
schedule:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
.github/workflows/post-dependabot.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot
on: pull_request
permissions:
contents: write
jobs:
template-oss:
name: template-oss
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: \${{ github.event.pull_request.head.ref }}
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: \${{ secrets.GITHUB_TOKEN }}
# Dependabot can update multiple directories so we output which directory
# it is acting on so we can run the command for the correct root or workspace
- name: Get Dependabot Directory
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
id: flags
run: |
dependabot_dir="\${{ steps.metadata.outputs.directory }}"
if [[ "$dependabot_dir" == "/" ]]; then
echo "workspace=-iwr" >> $GITHUB_OUTPUT
else
# strip leading slash from directory so it works as a
# a path to the workspace flag
echo "workspace=-w \${dependabot_dir#/}" >> $GITHUB_OUTPUT
fi
- name: Apply Changes
if: steps.flags.outputs.workspace
id: apply
run: |
npm run template-oss-apply \${{ steps.flags.outputs.workspace }}
if [[ \`git status --porcelain\` ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
# This only sets the conventional commit prefix. This workflow can't reliably determine
# what the breaking change is though. If a BREAKING CHANGE message is required then
# this PR check will fail and the commit will be amended with stafftools
if [[ "\${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
prefix='feat!'
else
prefix='chore'
fi
echo "message=$prefix: postinstall for dependabot template-oss PR" >> $GITHUB_OUTPUT
# This step will fail if template-oss has made any workflow updates. It is impossible
# for a workflow to update other workflows. In the case it does fail, we continue
# and then try to apply only a portion of the changes in the next step
- name: Push All Changes
if: steps.apply.outputs.changes
id: push
continue-on-error: true
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "\${{ steps.apply.outputs.message }}"
git push
# If the previous step failed, then reset the commit and remove any workflow changes
# and attempt to commit and push again. This is helpful because we will have a commit
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
- name: Push All Changes Except Workflows
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
run: |
git reset HEAD~
git checkout HEAD -- .github/workflows/
git clean -fd .github/workflows/
git commit -am "\${{ steps.apply.outputs.message }}"
git push
# Check if all the necessary template-oss changes were applied. Since we continued
# on errors in one of the previous steps, this check will fail if our follow up
# only applied a portion of the changes and we need to followup manually.
#
# Note that this used to run \`lint\` and \`postlint\` but that will fail this action
# if we've also shipped any linting changes separate from template-oss. We do
# linting in another action, so we want to fail this one only if there are
# template-oss changes that could not be applied.
- name: Check Changes
if: steps.apply.outputs.changes
run: |
npm exec --offline \${{ steps.flags.outputs.workspace }} -- template-oss-check
- name: Fail on Breaking Change
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
run: |
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
echo "for more information on how to fix this with a BREAKING CHANGE footer."
exit 1
.github/workflows/pull-request.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
commitlint:
name: Lint Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
id: commit
continue-on-error: true
run: npx --offline commitlint -V --from 'origin/\${{ github.base_ref }}' --to \${{ github.event.pull_request.head.sha }}
- name: Run Commitlint on PR Title
if: steps.commit.outcome == 'failure'
env:
PR_TITLE: \${{ github.event.pull_request.title }}
run: echo "$PR_TITLE" | npx --offline commitlint -V
.github/workflows/release-integration.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release Integration
on:
workflow_dispatch:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
workflow_call:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
jobs:
publish:
name: Check Publish
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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: Check If Published
run: |
EXIT_CODE=0
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
npm view "$SPEC" --json
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
echo "$SPEC ERROR"
else
echo "$SPEC OK"
fi
done
exit $EXIT_CODE
.github/workflows/release.yml
========================================
# This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
push:
branches:
- main
- latest
- release/v*
permissions:
contents: write
pull-requests: write
checks: write
jobs:
release:
outputs:
pr: \${{ steps.release.outputs.pr }}
pr-branch: \${{ steps.release.outputs.pr-branch }}
pr-number: \${{ steps.release.outputs.pr-number }}
pr-sha: \${{ steps.release.outputs.pr-sha }}
releases: \${{ steps.release.outputs.releases }}
comment-id: \${{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }}
check-id: \${{ steps.create-check.outputs.check-id }}
name: Release
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v4
id: node
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
id: release
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
run: npx --offline template-oss-release-please --branch="\${{ github.ref_name }}" --backport="" --defaultTag="latest"
- name: Create Release Manager Comment Text
if: steps.release.outputs.pr-number
uses: actions/github-script@v7
id: comment-text
with:
result-encoding: string
script: |
const { runId, repo: { owner, repo } } = context
const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId })
return['## Release Manager', \`Release workflow run: \${workflow.html_url}\`].join('/n/n')
- name: Find Release Manager Comment
uses: peter-evans/find-comment@v2
if: steps.release.outputs.pr-number
id: found-comment
with:
issue-number: \${{ steps.release.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: '## Release Manager'
- name: Create Release Manager Comment
id: create-comment
if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: \${{ steps.release.outputs.pr-number }}
body: \${{ steps.comment-text.outputs.result }}