@zairakai/js-dev-tools 3.20.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +11 -72
- package/.gitlab/ci/parts/base.yml +95 -0
- package/.gitlab/ci/parts/publish.yml +156 -0
- package/.gitlab/ci/parts/quality.yml +161 -0
- package/.gitlab/ci/parts/security.yml +40 -0
- package/.gitlab/ci/parts/updates.yml +60 -0
- package/.gitlab/ci/pipeline-js-app.yml +19 -38
- package/.gitlab/ci/pipeline-js-package.yml +23 -528
- package/README.md +92 -11
- package/config/.markdownlintignore +8 -1
- package/config/.prettierignore +13 -0
- package/config/.stylelintignore +13 -3
- package/config/eslint.config.js +7 -1
- package/config/knip.config.js +7 -3
- package/config/stylelint.config.js +1 -0
- package/package.json +46 -29
- package/scripts/build.sh +28 -28
- package/scripts/ci-quality.sh +6 -6
- package/scripts/config.sh +164 -148
- package/scripts/doctor.sh +12 -12
- package/scripts/eslint-fix.sh +8 -8
- package/scripts/eslint.sh +15 -15
- package/scripts/install-bats.sh +143 -146
- package/scripts/install-hooks.sh +108 -111
- package/scripts/install-markdownlint.sh +4 -4
- package/scripts/install-shellcheck.sh +135 -138
- package/scripts/knip.sh +7 -7
- package/scripts/markdownlint.sh +38 -38
- package/scripts/outdated.sh +30 -29
- package/scripts/prettier-fix.sh +13 -13
- package/scripts/prettier.sh +13 -13
- package/scripts/setup-project.sh +691 -629
- package/scripts/stylelint-fix.sh +26 -19
- package/scripts/stylelint.sh +27 -20
- package/scripts/test.sh +13 -11
- package/scripts/typecheck.sh +11 -11
- package/scripts/update-dependencies.mjs +552 -181
- package/scripts/validate-shellcheck.sh +18 -18
- package/stubs/githooks/commit-msg +24 -21
- package/stubs/githooks/pre-commit +19 -19
- package/stubs/githooks/pre-push +18 -18
- package/stubs/githooks/prepare-commit-msg +6 -6
- package/stubs/gitlab-ci/gitlab-ci.yml.stub +1 -1
- package/stubs/governance/CONTRIBUTING.md.stub +5 -3
- package/stubs/quality/eslint.config.js.stub +1 -1
- package/stubs/quality/knip.config.js.stub +1 -1
- package/stubs/style/prettier.config.js.stub +3 -3
- package/stubs/style/stylelint.config.js.stub +8 -1
- package/stubs/testing/vitest.config.js.stub +1 -1
- package/tools/make/bats.mk +3 -3
- package/tools/make/core.mk +3 -3
- package/tools/make/quality.mk +2 -1
- package/tools/make/variables.mk +1 -1
|
@@ -1,75 +1,56 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# ================================
|
|
1
|
+
# PIPELINE TEMPLATE - Laravel App JS/Frontend
|
|
2
|
+
# ================
|
|
4
3
|
# Provides JS/Frontend CI jobs for a Laravel application.
|
|
5
|
-
# Includes
|
|
6
|
-
# package
|
|
4
|
+
# Includes the files of parts/ that an application needs (base, security, quality, updates) and none of what only a
|
|
5
|
+
# package does (build, publish, release, documentation, cascade): nothing to disable.
|
|
7
6
|
#
|
|
8
7
|
# PHP jobs come from laravel-dev-tools (pipeline-laravel-app.yml).
|
|
9
8
|
# All js: job names never conflict with php: job names.
|
|
10
9
|
#
|
|
11
|
-
# Fullstack usage (recommended
|
|
12
|
-
#
|
|
10
|
+
# Fullstack usage (recommended - single include):
|
|
11
|
+
# ================
|
|
13
12
|
# include:
|
|
14
13
|
# - project: 'zairakai/php-packages/laravel-dev-tools'
|
|
15
14
|
# ref: main
|
|
16
15
|
# file: '.gitlab/ci/pipeline-laravel-fullstack.yml'
|
|
17
16
|
#
|
|
18
17
|
# Standalone usage (JS side only, alongside a custom PHP pipeline):
|
|
19
|
-
#
|
|
18
|
+
# ================
|
|
20
19
|
# include:
|
|
21
20
|
# - project: 'zairakai/npm-packages/js-dev-tools'
|
|
22
21
|
# ref: main
|
|
23
22
|
# file: '.gitlab/ci/pipeline-js-app.yml'
|
|
24
23
|
#
|
|
25
24
|
# variables:
|
|
26
|
-
# CACHE_KEY: "my-app-
|
|
27
|
-
# ================================
|
|
25
|
+
# CACHE_KEY: "my-app-v2"
|
|
28
26
|
|
|
29
27
|
include:
|
|
30
|
-
#
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
# security.yml first: the template of the secret detection it includes sets variables that base.yml overrides.
|
|
29
|
+
- local: '.gitlab/ci/parts/security.yml'
|
|
30
|
+
- local: '.gitlab/ci/parts/base.yml'
|
|
31
|
+
- local: '.gitlab/ci/parts/quality.yml'
|
|
32
|
+
- local: '.gitlab/ci/parts/updates.yml'
|
|
34
33
|
|
|
35
|
-
# ================================
|
|
36
34
|
# STAGES
|
|
37
|
-
#
|
|
38
|
-
# Merges with PHP pipeline stages
|
|
39
|
-
#
|
|
40
|
-
# in the merged list but stay empty (jobs below are disabled).
|
|
35
|
+
# ================
|
|
36
|
+
# Merges with PHP pipeline stages - GitLab deduplicates identical names.
|
|
37
|
+
# release is the stage of deps:release and deps:tag.
|
|
41
38
|
stages:
|
|
42
39
|
- security
|
|
43
40
|
- install
|
|
44
41
|
- validate
|
|
45
42
|
- quality
|
|
46
43
|
- test
|
|
44
|
+
- release
|
|
47
45
|
- deploy
|
|
48
46
|
- metrics
|
|
49
47
|
|
|
50
|
-
# ================================
|
|
51
48
|
# VARIABLES
|
|
52
|
-
#
|
|
49
|
+
# ================
|
|
53
50
|
variables:
|
|
54
51
|
# Default cache key for app context (overridden per project via CACHE_KEY).
|
|
55
|
-
CACHE_KEY:
|
|
52
|
+
CACHE_KEY: 'zairakai-laravel-app'
|
|
56
53
|
|
|
57
54
|
# Note: GIT_CLEAN_FLAGS intentionally NOT set here.
|
|
58
55
|
# pipeline-laravel-fullstack.yml sets the combined value to preserve
|
|
59
56
|
# both vendor/ and node_modules/.
|
|
60
|
-
|
|
61
|
-
# ================================
|
|
62
|
-
# DISABLE package-specific jobs
|
|
63
|
-
# Not relevant for a Laravel app (no npm publish or GitLab release).
|
|
64
|
-
# ================================
|
|
65
|
-
js:build:
|
|
66
|
-
rules:
|
|
67
|
-
- when: never
|
|
68
|
-
|
|
69
|
-
js:publish:
|
|
70
|
-
rules:
|
|
71
|
-
- when: never
|
|
72
|
-
|
|
73
|
-
js:release:
|
|
74
|
-
rules:
|
|
75
|
-
- when: never
|
|
@@ -1,55 +1,45 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# ================================
|
|
1
|
+
# PIPELINE TEMPLATE - NPM Package
|
|
2
|
+
# ================
|
|
4
3
|
# Shared pipeline template for NPM packages in the Zairakai namespace.
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
4
|
+
# The jobs are in the files of parts/, one per role, which pipeline-js-app.yml includes too (the part that an application
|
|
5
|
+
# needs): base (runner, variables, hidden jobs), security, quality (install, validate, quality, test), updates, and
|
|
6
|
+
# publish (build, publish, release, documentation, cascade: this file only).
|
|
7
|
+
# The files share their hidden jobs with extends:, because YAML anchors do not cross the files of an include.
|
|
8
8
|
#
|
|
9
9
|
# All job names are prefixed js: to avoid any collision with PHP or custom
|
|
10
10
|
# jobs when this template is combined with other templates.
|
|
11
|
-
# pipeline-js-app.yml (fullstack context) includes this file directly — no duplication.
|
|
12
11
|
#
|
|
13
12
|
# USAGE in a consumer project:
|
|
14
|
-
#
|
|
13
|
+
# ================
|
|
15
14
|
# include:
|
|
16
15
|
# - project: 'zairakai/npm-packages/js-dev-tools'
|
|
17
16
|
# ref: main
|
|
18
17
|
# file: '.gitlab/ci/pipeline-js-package.yml'
|
|
19
18
|
#
|
|
20
19
|
# variables:
|
|
21
|
-
# CACHE_KEY: "my-package-
|
|
20
|
+
# CACHE_KEY: "my-package-v2"
|
|
22
21
|
# NPM_PACKAGE_NAME: "@myorg/my-package"
|
|
23
22
|
#
|
|
24
23
|
# FOR dev-tools ITSELF (self-hosted mode):
|
|
25
|
-
#
|
|
24
|
+
# ================
|
|
26
25
|
# include:
|
|
27
26
|
# - local: '.gitlab/ci/pipeline-js-package.yml'
|
|
28
27
|
#
|
|
29
28
|
# variables:
|
|
30
|
-
# CACHE_KEY: "dev-tools-
|
|
29
|
+
# CACHE_KEY: "dev-tools-v2"
|
|
31
30
|
# NPM_PACKAGE_NAME: "@zairakai/js-dev-tools"
|
|
32
31
|
# JS_DEV_TOOLS_SCRIPTS: "scripts"
|
|
33
|
-
# ================================
|
|
34
32
|
|
|
35
33
|
include:
|
|
36
|
-
|
|
34
|
+
# security.yml first: the template of the secret detection it includes sets variables that base.yml overrides.
|
|
35
|
+
- local: '.gitlab/ci/parts/security.yml'
|
|
36
|
+
- local: '.gitlab/ci/parts/base.yml'
|
|
37
|
+
- local: '.gitlab/ci/parts/quality.yml'
|
|
38
|
+
- local: '.gitlab/ci/parts/updates.yml'
|
|
39
|
+
- local: '.gitlab/ci/parts/publish.yml'
|
|
37
40
|
|
|
38
|
-
# ================================
|
|
39
|
-
# WORKFLOW
|
|
40
|
-
# ================================
|
|
41
|
-
workflow:
|
|
42
|
-
rules:
|
|
43
|
-
- if: $CI_COMMIT_TAG
|
|
44
|
-
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
45
|
-
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
46
|
-
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
47
|
-
- if: $CI_COMMIT_REF_NAME =~ /^feature\// || $CI_COMMIT_REF_NAME =~ /^fix\// || $CI_COMMIT_REF_NAME =~ /^hotfix\//
|
|
48
|
-
- when: never
|
|
49
|
-
|
|
50
|
-
# ================================
|
|
51
41
|
# STAGES
|
|
52
|
-
#
|
|
42
|
+
# ================
|
|
53
43
|
stages:
|
|
54
44
|
- security
|
|
55
45
|
- install
|
|
@@ -60,505 +50,10 @@ stages:
|
|
|
60
50
|
- publish
|
|
61
51
|
- release
|
|
62
52
|
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
# ================================
|
|
66
|
-
# Every job runs on the self-hosted runner of the group, whatever the shared runners enabled on the project.
|
|
67
|
-
# Only js:publish leaves it: npm trusted publishing does not accept a self-hosted runner.
|
|
68
|
-
default:
|
|
69
|
-
tags:
|
|
70
|
-
- zairakai-ci
|
|
71
|
-
|
|
72
|
-
# ================================
|
|
73
|
-
# DEFAULT VARIABLES
|
|
74
|
-
# ================================
|
|
53
|
+
# VARIABLES
|
|
54
|
+
# ================
|
|
75
55
|
variables:
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# Paths to dev-tools scripts.
|
|
81
|
-
# Consumer projects do NOT need to override these.
|
|
82
|
-
# dev-tools itself overrides them in its own .gitlab-ci.yml.
|
|
83
|
-
JS_DEV_TOOLS_SCRIPTS: "node_modules/@zairakai/js-dev-tools/scripts"
|
|
84
|
-
|
|
85
|
-
# ── NODE ──────────────────────────────────────────────────────────────────
|
|
86
|
-
NODE_VERSION: "24"
|
|
87
|
-
NODE_IMAGE: "zairakai/node:latest-dev"
|
|
88
|
-
NODE_TEST_IMAGE: "zairakai/node:latest-test"
|
|
89
|
-
# The jobs of the automatic updates sign with gpg: the image has it since 1.3.0. It is an exact version, published on
|
|
90
|
-
# Docker Hub like our other images: the runner pulls it, whatever the old image it keeps locally.
|
|
91
|
-
NODE_UPDATE_IMAGE: "zairakai/node:1.3.0-dev"
|
|
92
|
-
SHELLCHECK_IMAGE: "koalaman/shellcheck-alpine:v0.10.0"
|
|
93
|
-
RELEASE_CLI_IMAGE: "registry.gitlab.com/gitlab-org/release-cli:v0.18.0"
|
|
94
|
-
ALPINE_IMAGE: "alpine:3.18"
|
|
95
|
-
|
|
96
|
-
# ── GIT ───────────────────────────────────────────────────────────────────
|
|
97
|
-
GIT_DEPTH: 1
|
|
98
|
-
GIT_STRATEGY: fetch
|
|
99
|
-
GIT_CLEAN_FLAGS: "-ffdx -e node_modules/ -e .npm/"
|
|
100
|
-
|
|
101
|
-
# ── SECURITY ──────────────────────────────────────────────────────────────
|
|
102
|
-
SECRET_DETECTION_EXCLUDED_PATHS: "node_modules/,dist/,build/,coverage/"
|
|
103
|
-
|
|
104
|
-
# ================================
|
|
105
|
-
# ANCHORS
|
|
106
|
-
# ================================
|
|
107
|
-
.base_job: &base_job
|
|
108
|
-
retry:
|
|
109
|
-
max: 2
|
|
110
|
-
when:
|
|
111
|
-
- runner_system_failure
|
|
112
|
-
- stuck_or_timeout_failure
|
|
113
|
-
|
|
114
|
-
.cache_node: &cache_node
|
|
115
|
-
cache:
|
|
116
|
-
key:
|
|
117
|
-
files:
|
|
118
|
-
- package-lock.json
|
|
119
|
-
prefix: $CACHE_KEY
|
|
120
|
-
paths:
|
|
121
|
-
- node_modules/
|
|
122
|
-
- .npm/
|
|
123
|
-
policy: pull
|
|
124
|
-
|
|
125
|
-
.cache_node_push: &cache_node_push
|
|
126
|
-
cache:
|
|
127
|
-
key:
|
|
128
|
-
files:
|
|
129
|
-
- package-lock.json
|
|
130
|
-
prefix: $CACHE_KEY
|
|
131
|
-
paths:
|
|
132
|
-
- node_modules/
|
|
133
|
-
- .npm/
|
|
134
|
-
policy: pull-push
|
|
135
|
-
|
|
136
|
-
.job_node: &job_node
|
|
137
|
-
<<: [*base_job, *cache_node]
|
|
138
|
-
image: ${NODE_IMAGE}
|
|
139
|
-
before_script:
|
|
140
|
-
- node --version
|
|
141
|
-
- npm --version
|
|
142
|
-
|
|
143
|
-
# ================================
|
|
144
|
-
# SECURITY
|
|
145
|
-
# ================================
|
|
146
|
-
secret_detection:
|
|
147
|
-
stage: security
|
|
148
|
-
rules:
|
|
149
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
150
|
-
when: never
|
|
151
|
-
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
152
|
-
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
153
|
-
|
|
154
|
-
# A tag whose format is not the one of VERSION_TAG_REGEX (group variable) fails here,
|
|
155
|
-
# and the jobs that publish do not run for it.
|
|
156
|
-
js:tag-format:
|
|
157
|
-
<<: *base_job
|
|
158
|
-
stage: security
|
|
159
|
-
image: ${ALPINE_IMAGE}
|
|
160
|
-
rules:
|
|
161
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
162
|
-
when: never
|
|
163
|
-
- if: $CI_COMMIT_TAG
|
|
164
|
-
script:
|
|
165
|
-
- |
|
|
166
|
-
regex="${VERSION_TAG_REGEX:-}"
|
|
167
|
-
regex="${regex#/}"
|
|
168
|
-
regex="${regex%/}"
|
|
169
|
-
if [ -z "$regex" ]; then
|
|
170
|
-
echo "ERROR: VERSION_TAG_REGEX is not set. It is a variable of the zairakai group."
|
|
171
|
-
exit 1
|
|
172
|
-
fi
|
|
173
|
-
if ! printf '%s\n' "$CI_COMMIT_TAG" | grep -Eq "$regex"; then
|
|
174
|
-
echo "ERROR: the tag \"$CI_COMMIT_TAG\" does not match $VERSION_TAG_REGEX (X.Y.Z or X.Y.Z-prerelease)."
|
|
175
|
-
exit 1
|
|
176
|
-
fi
|
|
177
|
-
echo "Tag $CI_COMMIT_TAG: format OK"
|
|
178
|
-
|
|
179
|
-
# ================================
|
|
180
|
-
# INSTALL
|
|
181
|
-
# ================================
|
|
182
|
-
js:install:
|
|
183
|
-
<<: [*base_job, *cache_node_push]
|
|
184
|
-
stage: install
|
|
185
|
-
rules:
|
|
186
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
187
|
-
when: never
|
|
188
|
-
- when: on_success
|
|
189
|
-
image: ${NODE_IMAGE}
|
|
190
|
-
script:
|
|
191
|
-
- npm ci --cache .npm --prefer-offline
|
|
192
|
-
- |
|
|
193
|
-
if [ -f /lib/ld-musl-x86_64.so.1 ]; then
|
|
194
|
-
npm install --no-save @oxc-resolver/binding-linux-x64-musl @rollup/rollup-linux-x64-musl
|
|
195
|
-
fi
|
|
196
|
-
artifacts:
|
|
197
|
-
paths:
|
|
198
|
-
- node_modules/
|
|
199
|
-
expire_in: 1 hour
|
|
200
|
-
|
|
201
|
-
# ================================
|
|
202
|
-
# VALIDATE
|
|
203
|
-
# ================================
|
|
204
|
-
js:validate:markdownlint:
|
|
205
|
-
<<: [*base_job, *cache_node]
|
|
206
|
-
stage: validate
|
|
207
|
-
rules:
|
|
208
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
209
|
-
when: never
|
|
210
|
-
- when: on_success
|
|
211
|
-
image: ${NODE_IMAGE}
|
|
212
|
-
script:
|
|
213
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/markdownlint.sh"
|
|
214
|
-
|
|
215
|
-
js:validate:shellcheck:
|
|
216
|
-
<<: *base_job
|
|
217
|
-
stage: validate
|
|
218
|
-
rules:
|
|
219
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
220
|
-
when: never
|
|
221
|
-
- when: on_success
|
|
222
|
-
image: ${SHELLCHECK_IMAGE}
|
|
223
|
-
before_script:
|
|
224
|
-
- apk add --no-cache bash
|
|
225
|
-
script:
|
|
226
|
-
- |
|
|
227
|
-
if [[ -d scripts/ ]]; then
|
|
228
|
-
bash "$JS_DEV_TOOLS_SCRIPTS/validate-shellcheck.sh"
|
|
229
|
-
else
|
|
230
|
-
echo "No scripts/ directory found — skipping ShellCheck"
|
|
231
|
-
fi
|
|
232
|
-
|
|
233
|
-
# ================================
|
|
234
|
-
# QUALITY
|
|
235
|
-
# ================================
|
|
236
|
-
js:quality:lint:
|
|
237
|
-
<<: *job_node
|
|
238
|
-
stage: quality
|
|
239
|
-
rules:
|
|
240
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
241
|
-
when: never
|
|
242
|
-
- when: on_success
|
|
243
|
-
script:
|
|
244
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/eslint.sh"
|
|
245
|
-
artifacts:
|
|
246
|
-
reports:
|
|
247
|
-
junit: build/reports/eslint.xml
|
|
248
|
-
paths:
|
|
249
|
-
- build/reports/
|
|
250
|
-
expire_in: 1 week
|
|
251
|
-
when: always
|
|
252
|
-
|
|
253
|
-
js:quality:format:
|
|
254
|
-
<<: *job_node
|
|
255
|
-
stage: quality
|
|
256
|
-
rules:
|
|
257
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
258
|
-
when: never
|
|
259
|
-
- when: on_success
|
|
260
|
-
script:
|
|
261
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/prettier.sh"
|
|
262
|
-
|
|
263
|
-
js:quality:stylelint:
|
|
264
|
-
<<: *job_node
|
|
265
|
-
stage: quality
|
|
266
|
-
rules:
|
|
267
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
268
|
-
when: never
|
|
269
|
-
- when: on_success
|
|
270
|
-
script:
|
|
271
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/stylelint.sh"
|
|
272
|
-
|
|
273
|
-
js:quality:typecheck:
|
|
274
|
-
<<: *job_node
|
|
275
|
-
stage: quality
|
|
276
|
-
rules:
|
|
277
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
278
|
-
when: never
|
|
279
|
-
- when: on_success
|
|
280
|
-
script:
|
|
281
|
-
- |
|
|
282
|
-
if [ -f tsconfig.json ] && [ -f node_modules/.bin/tsc ]; then
|
|
283
|
-
bash "$JS_DEV_TOOLS_SCRIPTS/typecheck.sh"
|
|
284
|
-
else
|
|
285
|
-
echo "TypeScript not configured — skipping (add tsconfig.json + typescript to devDependencies)"
|
|
286
|
-
fi
|
|
287
|
-
|
|
288
|
-
js:quality:knip:
|
|
289
|
-
<<: *job_node
|
|
290
|
-
stage: quality
|
|
291
|
-
rules:
|
|
292
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
293
|
-
when: never
|
|
294
|
-
- when: on_success
|
|
295
|
-
script:
|
|
296
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/knip.sh"
|
|
297
|
-
|
|
298
|
-
js:quality:bats:
|
|
299
|
-
<<: [*base_job, *cache_node]
|
|
300
|
-
stage: quality
|
|
301
|
-
rules:
|
|
302
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
303
|
-
when: never
|
|
304
|
-
- when: on_success
|
|
305
|
-
image: ${ALPINE_IMAGE}
|
|
306
|
-
before_script:
|
|
307
|
-
- apk add --no-cache bash bats git
|
|
308
|
-
script:
|
|
309
|
-
- |
|
|
310
|
-
if [[ -d tests/bats ]]; then
|
|
311
|
-
bats tests/bats --recursive
|
|
312
|
-
else
|
|
313
|
-
echo "No BATS tests found — skipping"
|
|
314
|
-
fi
|
|
315
|
-
|
|
316
|
-
js:quality:outdated:
|
|
317
|
-
<<: *job_node
|
|
318
|
-
stage: quality
|
|
319
|
-
rules:
|
|
320
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
321
|
-
when: never
|
|
322
|
-
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
323
|
-
script:
|
|
324
|
-
- bash "$JS_DEV_TOOLS_SCRIPTS/outdated.sh"
|
|
325
|
-
artifacts:
|
|
326
|
-
paths:
|
|
327
|
-
- build/reports/npm-outdated.json
|
|
328
|
-
expire_in: 1 week
|
|
329
|
-
when: always
|
|
330
|
-
|
|
331
|
-
# ================================
|
|
332
|
-
# TEST
|
|
333
|
-
# ================================
|
|
334
|
-
js:test:
|
|
335
|
-
<<: [*base_job, *cache_node]
|
|
336
|
-
stage: test
|
|
337
|
-
rules:
|
|
338
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
339
|
-
when: never
|
|
340
|
-
- when: on_success
|
|
341
|
-
image: ${NODE_TEST_IMAGE}
|
|
342
|
-
script:
|
|
343
|
-
- CI=true bash "$JS_DEV_TOOLS_SCRIPTS/test.sh"
|
|
344
|
-
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
|
|
345
|
-
artifacts:
|
|
346
|
-
reports:
|
|
347
|
-
junit: build/coverage/junit.xml
|
|
348
|
-
coverage_report:
|
|
349
|
-
coverage_format: cobertura
|
|
350
|
-
path: build/coverage/cobertura-coverage.xml
|
|
351
|
-
paths:
|
|
352
|
-
- build/coverage/
|
|
353
|
-
expire_in: 1 week
|
|
354
|
-
when: always
|
|
355
|
-
|
|
356
|
-
# ================================
|
|
357
|
-
# BUILD
|
|
358
|
-
# ================================
|
|
359
|
-
js:build:
|
|
360
|
-
<<: *job_node
|
|
361
|
-
stage: build
|
|
362
|
-
script:
|
|
363
|
-
- |
|
|
364
|
-
if { [ -f node_modules/.bin/tsup ] || [ -f node_modules/.bin/tsc ]; } && [ -f tsconfig.json ]; then
|
|
365
|
-
bash "$JS_DEV_TOOLS_SCRIPTS/build.sh"
|
|
366
|
-
else
|
|
367
|
-
echo "No TypeScript builder configured — skipping (install tsup or typescript)"
|
|
368
|
-
fi
|
|
369
|
-
artifacts:
|
|
370
|
-
paths:
|
|
371
|
-
- dist/
|
|
372
|
-
expire_in: 1 week
|
|
373
|
-
when: on_success
|
|
374
|
-
rules:
|
|
375
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
376
|
-
when: never
|
|
377
|
-
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
378
|
-
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
379
|
-
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
380
|
-
|
|
381
|
-
# ================================
|
|
382
|
-
# PUBLISH
|
|
383
|
-
# ================================
|
|
384
|
-
js:publish:
|
|
385
|
-
<<: [*base_job, *cache_node]
|
|
386
|
-
stage: publish
|
|
387
|
-
image: ${NODE_IMAGE}
|
|
388
|
-
# Trusted publishing: npm trusts this project and this job, and the OIDC token below authenticates the publication.
|
|
389
|
-
# No npm token is stored anywhere. npm accepts only the shared runners of GitLab.com (not a self-hosted runner),
|
|
390
|
-
# so this job is the only one that uses them. The tag is the one of GitLab, it cannot be renamed.
|
|
391
|
-
tags:
|
|
392
|
-
- saas-linux-small-amd64
|
|
393
|
-
id_tokens:
|
|
394
|
-
NPM_ID_TOKEN:
|
|
395
|
-
aud: "npm:registry.npmjs.org"
|
|
396
|
-
# Lets npm sign the provenance: the package page shows it was built on GitLab from this project.
|
|
397
|
-
SIGSTORE_ID_TOKEN:
|
|
398
|
-
aud: sigstore
|
|
399
|
-
rules:
|
|
400
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
401
|
-
when: never
|
|
402
|
-
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
403
|
-
script:
|
|
404
|
-
- |
|
|
405
|
-
# A pre-release (2.3.0-rc.1) goes to the npm tag "next", so it never becomes "latest"
|
|
406
|
-
npm_tag="latest"
|
|
407
|
-
if [[ $CI_COMMIT_TAG == *-* ]]; then
|
|
408
|
-
npm_tag="next"
|
|
409
|
-
fi
|
|
410
|
-
echo "Publishing ${NPM_PACKAGE_NAME}@${CI_COMMIT_TAG} to npm (tag ${npm_tag})..."
|
|
411
|
-
npm version "${CI_COMMIT_TAG}" --no-git-tag-version --allow-same-version
|
|
412
|
-
npm publish --provenance --access public --tag "${npm_tag}"
|
|
413
|
-
environment:
|
|
414
|
-
name: production
|
|
415
|
-
url: https://www.npmjs.com/package/${NPM_PACKAGE_NAME}
|
|
416
|
-
|
|
417
|
-
# ================================
|
|
418
|
-
# RELEASE
|
|
419
|
-
# ================================
|
|
420
|
-
js:release:
|
|
421
|
-
<<: *base_job
|
|
422
|
-
stage: release
|
|
423
|
-
image: ${RELEASE_CLI_IMAGE}
|
|
424
|
-
rules:
|
|
425
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
426
|
-
when: never
|
|
427
|
-
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
428
|
-
before_script:
|
|
429
|
-
- apk add --no-cache bash git jq
|
|
430
|
-
- git config --global --add safe.directory '*'
|
|
431
|
-
- git config --global user.name "GitLab CI"
|
|
432
|
-
- git config --global user.email "ci@gitlab.com"
|
|
433
|
-
script:
|
|
434
|
-
- |
|
|
435
|
-
# Tags are listed newest first, with or without the old "v" prefix (v2.1.0 then 2.2.0)
|
|
436
|
-
PREVIOUS_TAG=$(git tag | sed -E 's/^v?(.*)$/\1 &/' | sort -k1,1 -Vr | cut -d' ' -f2 | grep -A1 -Fx "${CI_COMMIT_TAG}" | tail -n 1 || echo "")
|
|
437
|
-
if [[ -n "$PREVIOUS_TAG" && "$PREVIOUS_TAG" != "$CI_COMMIT_TAG" ]]; then
|
|
438
|
-
COMMITS=$(git log --pretty=format:"- %s" "${PREVIOUS_TAG}..${CI_COMMIT_TAG}" | head -20)
|
|
439
|
-
else
|
|
440
|
-
COMMITS="- Initial release"
|
|
441
|
-
fi
|
|
442
|
-
cat > release_notes.md << NOTES
|
|
443
|
-
## ${CI_COMMIT_TAG}
|
|
444
|
-
|
|
445
|
-
${COMMITS}
|
|
446
|
-
NOTES
|
|
447
|
-
release-cli create \
|
|
448
|
-
--tag-name "${CI_COMMIT_TAG}" \
|
|
449
|
-
--name "Release ${CI_COMMIT_TAG}" \
|
|
450
|
-
--description "$(cat release_notes.md)" \
|
|
451
|
-
--assets-link "{\"name\":\"npm\",\"url\":\"https://www.npmjs.com/package/${NPM_PACKAGE_NAME}/v/${CI_COMMIT_TAG}\"}"
|
|
452
|
-
artifacts:
|
|
453
|
-
paths:
|
|
454
|
-
- release_notes.md
|
|
455
|
-
expire_in: 1 year
|
|
456
|
-
|
|
457
|
-
# ================================
|
|
458
|
-
# DOCUMENTATION
|
|
459
|
-
# ================================
|
|
460
|
-
# The documentation site (GitLab Pages): every released version, each built from its own tag, and next, with a version
|
|
461
|
-
# selector. See docs/scripts/publish.sh in the project. It comes with the release: a tag is always a release of main, and
|
|
462
|
-
# nothing is published if the publication failed. The dependencies are the ones installed once by js:install.
|
|
463
|
-
# A project without docs/scripts/publish.sh has no site.
|
|
464
|
-
pages:
|
|
465
|
-
<<: [*base_job, *cache_node]
|
|
466
|
-
stage: release
|
|
467
|
-
image: ${NODE_IMAGE}
|
|
468
|
-
needs:
|
|
469
|
-
- job: js:install
|
|
470
|
-
- job: js:publish
|
|
471
|
-
variables:
|
|
472
|
-
GIT_DEPTH: 0
|
|
473
|
-
before_script:
|
|
474
|
-
- node --version
|
|
475
|
-
script:
|
|
476
|
-
- bash docs/scripts/publish.sh
|
|
477
|
-
# The next jobs of the runner must not find (and lint) the docs dependencies or what they generate.
|
|
478
|
-
after_script:
|
|
479
|
-
- rm -rf docs/node_modules docs/.vitepress/dist docs/.vitepress/cache
|
|
480
|
-
- git clean -fdXq docs || true
|
|
481
|
-
artifacts:
|
|
482
|
-
paths:
|
|
483
|
-
- public
|
|
484
|
-
expire_in: 1 week
|
|
485
|
-
rules:
|
|
486
|
-
- if: $UPDATE_DEPENDENCIES == "true"
|
|
487
|
-
when: never
|
|
488
|
-
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
489
|
-
exists:
|
|
490
|
-
- docs/scripts/publish.sh
|
|
491
|
-
|
|
492
|
-
# ================================
|
|
493
|
-
# AUTOMATIC UPDATES
|
|
494
|
-
# ================================
|
|
495
|
-
# See the handbook, policies/dependency-management.md. The exceptions of a project live in .dependency-update.json.
|
|
496
|
-
# The group variable GITLAB_TOKEN (protected, so these jobs run on main, develop and the tags) opens the merge requests,
|
|
497
|
-
# merges them and creates the tags. The pipeline of each merge request is the gate: nothing is tested by these jobs.
|
|
498
|
-
|
|
499
|
-
# A weekly schedule (or a pipeline started by the cascade) with UPDATE_DEPENDENCIES=true prepares the update.
|
|
500
|
-
deps:update:
|
|
501
|
-
<<: *base_job
|
|
502
|
-
stage: install
|
|
503
|
-
image: ${NODE_UPDATE_IMAGE}
|
|
504
|
-
needs: []
|
|
505
|
-
script:
|
|
506
|
-
- node --version
|
|
507
|
-
- "[ -d node_modules ] || npm ci --no-audit --no-fund"
|
|
508
|
-
- '[ "${JS_DEV_TOOLS_SCRIPTS}" = "scripts" ] || npm install --no-save --no-audit --no-fund "@zairakai/js-dev-tools@latest"'
|
|
509
|
-
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" update
|
|
510
|
-
rules:
|
|
511
|
-
- if: $UPDATE_DEPENDENCIES == "true" && $AUDIT_DEPENDENCIES != "true" && $CI_COMMIT_BRANCH == "develop"
|
|
512
|
-
|
|
513
|
-
# A daily schedule with UPDATE_DEPENDENCIES=true and AUDIT_DEPENDENCIES=true looks for security advisories: one issue per
|
|
514
|
-
# advisory (ntfy alert, closed when it is gone) and, with the group variable AUTO_FIX=true, an update started to fix it.
|
|
515
|
-
# The token FRESHNESS_TOKEN of the group (else GITLAB_TOKEN) opens the issues and starts the update; NTFY_URL is the alert.
|
|
516
|
-
deps:audit:
|
|
517
|
-
<<: *base_job
|
|
518
|
-
stage: install
|
|
519
|
-
image: ${NODE_UPDATE_IMAGE}
|
|
520
|
-
needs: []
|
|
521
|
-
script:
|
|
522
|
-
- node --version
|
|
523
|
-
- "[ -d node_modules ] || npm ci --no-audit --no-fund"
|
|
524
|
-
- '[ "${JS_DEV_TOOLS_SCRIPTS}" = "scripts" ] || npm install --no-save --no-audit --no-fund "@zairakai/js-dev-tools@latest"'
|
|
525
|
-
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" audit
|
|
526
|
-
rules:
|
|
527
|
-
- if: $UPDATE_DEPENDENCIES == "true" && $AUDIT_DEPENDENCIES == "true" && $CI_COMMIT_BRANCH == "develop"
|
|
528
|
-
|
|
529
|
-
# After the merge of an update into develop, bring develop into main.
|
|
530
|
-
deps:release:
|
|
531
|
-
<<: *base_job
|
|
532
|
-
stage: release
|
|
533
|
-
image: ${NODE_IMAGE}
|
|
534
|
-
script:
|
|
535
|
-
- "[ -d node_modules ] || npm ci --no-audit --no-fund"
|
|
536
|
-
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" release
|
|
537
|
-
rules:
|
|
538
|
-
- if: $CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_MESSAGE =~ /chore\/update-dependencies/
|
|
539
|
-
|
|
540
|
-
# After the merge of an update into main, tag it when a published range changed. The tag starts the publication.
|
|
541
|
-
deps:tag:
|
|
542
|
-
<<: *base_job
|
|
543
|
-
stage: release
|
|
544
|
-
image: ${NODE_UPDATE_IMAGE}
|
|
545
|
-
variables:
|
|
546
|
-
GIT_DEPTH: 0
|
|
547
|
-
script:
|
|
548
|
-
- "[ -d node_modules ] || npm ci --no-audit --no-fund"
|
|
549
|
-
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" tag
|
|
550
|
-
rules:
|
|
551
|
-
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
|
|
552
|
-
|
|
553
|
-
# After the publication, start the update of the projects that use this package (only if the project has a cascade).
|
|
554
|
-
deps:cascade:
|
|
555
|
-
<<: *base_job
|
|
556
|
-
stage: release
|
|
557
|
-
image: ${NODE_IMAGE}
|
|
558
|
-
needs:
|
|
559
|
-
- job: js:publish
|
|
560
|
-
script:
|
|
561
|
-
- "[ -d node_modules ] || npm ci --no-audit --no-fund"
|
|
562
|
-
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" cascade
|
|
563
|
-
rules:
|
|
564
|
-
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
56
|
+
# OVERRIDE PER PROJECT
|
|
57
|
+
# ================
|
|
58
|
+
CACHE_KEY: 'zairakai-npm-package'
|
|
59
|
+
NPM_PACKAGE_NAME: '@zairakai/package'
|