@zairakai/js-dev-tools 3.20.0 → 4.0.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 +45 -28
- 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 +17 -17
- package/scripts/stylelint.sh +18 -18
- 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/variables.mk +1 -1
package/.editorconfig
CHANGED
|
@@ -1,86 +1,25 @@
|
|
|
1
|
-
# ===============================================
|
|
2
|
-
# EDITORCONFIG
|
|
3
|
-
# Coding standards for consistent formatting
|
|
4
|
-
# ===============================================
|
|
5
|
-
|
|
6
1
|
root = true
|
|
7
2
|
|
|
8
|
-
# ======================
|
|
9
|
-
# ALL FILES
|
|
10
|
-
# ======================
|
|
11
3
|
[*]
|
|
12
4
|
charset = utf-8
|
|
13
5
|
end_of_line = lf
|
|
14
|
-
indent_size =
|
|
6
|
+
indent_size = 2
|
|
15
7
|
indent_style = space
|
|
16
8
|
insert_final_newline = true
|
|
17
9
|
trim_trailing_whitespace = true
|
|
18
10
|
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[markdown]
|
|
23
|
-
indent_style = space
|
|
24
|
-
indent_size = 4
|
|
25
|
-
trim_trailing_whitespace = false
|
|
26
|
-
insert_final_newline = true
|
|
27
|
-
max_line_length = 120
|
|
28
|
-
|
|
29
|
-
[*.md]
|
|
30
|
-
trim_trailing_whitespace = false
|
|
31
|
-
|
|
32
|
-
# ======================
|
|
33
|
-
# SHELL SCRIPTS
|
|
34
|
-
# ======================
|
|
35
|
-
[*.sh]
|
|
36
|
-
end_of_line = lf
|
|
11
|
+
# Google JavaScript Style Guide: 80 columns
|
|
12
|
+
[*.{cjs,cts,js,mjs,mts,ts}]
|
|
13
|
+
max_line_length = 80
|
|
37
14
|
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
# ======================
|
|
41
|
-
[*.{yml,yaml}]
|
|
15
|
+
# Google Shell Style Guide: 2 spaces, 80 columns
|
|
16
|
+
[*.{bash,bats,sh}]
|
|
42
17
|
indent_size = 2
|
|
18
|
+
max_line_length = 80
|
|
43
19
|
|
|
44
|
-
[
|
|
45
|
-
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
indent_size = unset
|
|
46
23
|
|
|
47
|
-
|
|
48
|
-
# BUILD FILES
|
|
49
|
-
# ======================
|
|
50
|
-
[Makefile]
|
|
24
|
+
[{Makefile,*.mk}]
|
|
51
25
|
indent_style = tab
|
|
52
|
-
|
|
53
|
-
[Dockerfile*]
|
|
54
|
-
indent_size = 4
|
|
55
|
-
|
|
56
|
-
# ======================
|
|
57
|
-
# CONFIGURATION FILES
|
|
58
|
-
# ======================
|
|
59
|
-
[*.{ini,conf}]
|
|
60
|
-
indent_size = 4
|
|
61
|
-
|
|
62
|
-
# ======================
|
|
63
|
-
# FRONTEND FILES
|
|
64
|
-
# ======================
|
|
65
|
-
[*.json]
|
|
66
|
-
indent_size = 2
|
|
67
|
-
|
|
68
|
-
# ======================
|
|
69
|
-
# PHP FILES
|
|
70
|
-
# ======================
|
|
71
|
-
[*.php]
|
|
72
|
-
indent_size = 4
|
|
73
|
-
max_line_length = 120
|
|
74
|
-
|
|
75
|
-
# ======================
|
|
76
|
-
# Test FILES
|
|
77
|
-
# ======================
|
|
78
|
-
[*.feature]
|
|
79
|
-
charset = utf-8
|
|
80
|
-
gherkin_indent_feature_children = true
|
|
81
|
-
gherkin_indent_steps = true
|
|
82
|
-
gherkin_indent_datatable = true
|
|
83
|
-
gherkin_indent_docstring = true
|
|
84
|
-
gherkin_indent_examples_table = true
|
|
85
|
-
gherkin_table_cell_padding_size = 2
|
|
86
|
-
gherkin_table_cell_right_align_numeric_content = true
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# JS PIPELINE - BASE
|
|
2
|
+
# ================
|
|
3
|
+
# What every js: job shares: the workflow, the runner, the variables and the hidden jobs that the other files extend.
|
|
4
|
+
# Hidden jobs (extends:) replace the YAML anchors, which do not cross the files of an include.
|
|
5
|
+
# Included by pipeline-js-package.yml and pipeline-js-app.yml, with the other files of parts/.
|
|
6
|
+
|
|
7
|
+
# WORKFLOW
|
|
8
|
+
# ================
|
|
9
|
+
workflow:
|
|
10
|
+
rules:
|
|
11
|
+
- if: $CI_COMMIT_TAG
|
|
12
|
+
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
13
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
14
|
+
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
15
|
+
- if: $CI_COMMIT_REF_NAME =~ /^feature\// || $CI_COMMIT_REF_NAME =~ /^fix\// || $CI_COMMIT_REF_NAME =~ /^hotfix\//
|
|
16
|
+
- when: never
|
|
17
|
+
|
|
18
|
+
# RUNNERS
|
|
19
|
+
# ================
|
|
20
|
+
# Every job runs on the self-hosted runner of the group, whatever the shared runners enabled on the project.
|
|
21
|
+
# Only js:publish leaves it: npm trusted publishing does not accept a self-hosted runner.
|
|
22
|
+
default:
|
|
23
|
+
tags:
|
|
24
|
+
- zairakai-ci
|
|
25
|
+
|
|
26
|
+
# DEFAULT VARIABLES
|
|
27
|
+
# ================
|
|
28
|
+
variables:
|
|
29
|
+
# Paths to dev-tools scripts.
|
|
30
|
+
# Consumer projects do NOT need to override these.
|
|
31
|
+
# dev-tools itself overrides them in its own .gitlab-ci.yml.
|
|
32
|
+
JS_DEV_TOOLS_SCRIPTS: 'node_modules/@zairakai/js-dev-tools/scripts'
|
|
33
|
+
|
|
34
|
+
# NODE
|
|
35
|
+
# ================
|
|
36
|
+
NODE_VERSION: '24'
|
|
37
|
+
NODE_IMAGE: 'zairakai/node:latest-dev'
|
|
38
|
+
NODE_TEST_IMAGE: 'zairakai/node:latest-test'
|
|
39
|
+
# The jobs of the automatic updates sign with gpg: the image has it since 1.3.0. It is an exact version, published on
|
|
40
|
+
# Docker Hub like our other images: the runner pulls it, whatever the old image it keeps locally.
|
|
41
|
+
NODE_UPDATE_IMAGE: 'zairakai/node:1.3.0-dev'
|
|
42
|
+
SHELLCHECK_IMAGE: 'koalaman/shellcheck-alpine:v0.10.0'
|
|
43
|
+
RELEASE_CLI_IMAGE: 'registry.gitlab.com/gitlab-org/release-cli:v0.18.0'
|
|
44
|
+
ALPINE_IMAGE: 'alpine:3.18'
|
|
45
|
+
|
|
46
|
+
# GIT
|
|
47
|
+
# ================
|
|
48
|
+
GIT_DEPTH: 1
|
|
49
|
+
GIT_STRATEGY: fetch
|
|
50
|
+
GIT_CLEAN_FLAGS: '-ffdx -e node_modules/ -e .npm/'
|
|
51
|
+
|
|
52
|
+
# SECURITY
|
|
53
|
+
# ================
|
|
54
|
+
SECRET_DETECTION_EXCLUDED_PATHS: 'node_modules/,vendor/,dist/,build/,coverage/,docs/,public/,storage/,.nuxt/,.output/,storybook-static/'
|
|
55
|
+
|
|
56
|
+
# HIDDEN JOBS
|
|
57
|
+
# ================
|
|
58
|
+
.js:base:
|
|
59
|
+
retry:
|
|
60
|
+
max: 2
|
|
61
|
+
when:
|
|
62
|
+
- runner_system_failure
|
|
63
|
+
- stuck_or_timeout_failure
|
|
64
|
+
|
|
65
|
+
.js:cache:
|
|
66
|
+
cache:
|
|
67
|
+
key:
|
|
68
|
+
files:
|
|
69
|
+
- package-lock.json
|
|
70
|
+
prefix: $CACHE_KEY
|
|
71
|
+
paths:
|
|
72
|
+
- node_modules/
|
|
73
|
+
- .npm/
|
|
74
|
+
policy: pull
|
|
75
|
+
|
|
76
|
+
.js:cache-push:
|
|
77
|
+
extends: .js:cache
|
|
78
|
+
cache:
|
|
79
|
+
policy: pull-push
|
|
80
|
+
|
|
81
|
+
.js:node:
|
|
82
|
+
extends:
|
|
83
|
+
- .js:base
|
|
84
|
+
- .js:cache
|
|
85
|
+
image: ${NODE_IMAGE}
|
|
86
|
+
before_script:
|
|
87
|
+
- node --version
|
|
88
|
+
- npm --version
|
|
89
|
+
|
|
90
|
+
# The jobs that run unless the pipeline is an automatic update (UPDATE_DEPENDENCIES=true).
|
|
91
|
+
.js:rules:
|
|
92
|
+
rules:
|
|
93
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
94
|
+
when: never
|
|
95
|
+
- when: on_success
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# JS PIPELINE - BUILD, PUBLISH, RELEASE AND DOCUMENTATION
|
|
2
|
+
# ================
|
|
3
|
+
# What only a package does: build it, publish it on npm, release it, publish its documentation and start the update of the
|
|
4
|
+
# projects that use it. An application does not include this file.
|
|
5
|
+
# Included by pipeline-js-package.yml.
|
|
6
|
+
|
|
7
|
+
# BUILD
|
|
8
|
+
# ================
|
|
9
|
+
js:build:
|
|
10
|
+
extends: .js:node
|
|
11
|
+
stage: build
|
|
12
|
+
script:
|
|
13
|
+
- |
|
|
14
|
+
if { [ -f node_modules/.bin/tsup ] || [ -f node_modules/.bin/tsc ]; } && [ -f tsconfig.json ]; then
|
|
15
|
+
bash "$JS_DEV_TOOLS_SCRIPTS/build.sh"
|
|
16
|
+
else
|
|
17
|
+
echo "No TypeScript builder configured - skipping (install tsup or typescript)"
|
|
18
|
+
fi
|
|
19
|
+
artifacts:
|
|
20
|
+
paths:
|
|
21
|
+
- dist/
|
|
22
|
+
expire_in: 1 week
|
|
23
|
+
when: on_success
|
|
24
|
+
rules:
|
|
25
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
26
|
+
when: never
|
|
27
|
+
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
28
|
+
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
29
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
30
|
+
|
|
31
|
+
# PUBLISH
|
|
32
|
+
# ================
|
|
33
|
+
js:publish:
|
|
34
|
+
extends:
|
|
35
|
+
- .js:base
|
|
36
|
+
- .js:cache
|
|
37
|
+
stage: publish
|
|
38
|
+
image: ${NODE_IMAGE}
|
|
39
|
+
# Trusted publishing: npm trusts this project and this job, and the OIDC token below authenticates the publication.
|
|
40
|
+
# No npm token is stored anywhere. npm accepts only the shared runners of GitLab.com (not a self-hosted runner),
|
|
41
|
+
# so this job is the only one that uses them. The tag is the one of GitLab, it cannot be renamed.
|
|
42
|
+
tags:
|
|
43
|
+
- saas-linux-small-amd64
|
|
44
|
+
id_tokens:
|
|
45
|
+
NPM_ID_TOKEN:
|
|
46
|
+
aud: 'npm:registry.npmjs.org'
|
|
47
|
+
# Lets npm sign the provenance: the package page shows it was built on GitLab from this project.
|
|
48
|
+
SIGSTORE_ID_TOKEN:
|
|
49
|
+
aud: sigstore
|
|
50
|
+
rules:
|
|
51
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
52
|
+
when: never
|
|
53
|
+
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
54
|
+
script:
|
|
55
|
+
- |
|
|
56
|
+
# A pre-release (2.3.0-rc.1) goes to the npm tag "next", so it never becomes "latest"
|
|
57
|
+
npm_tag="latest"
|
|
58
|
+
if [[ $CI_COMMIT_TAG == *-* ]]; then
|
|
59
|
+
npm_tag="next"
|
|
60
|
+
fi
|
|
61
|
+
echo "Publishing ${NPM_PACKAGE_NAME}@${CI_COMMIT_TAG} to npm (tag ${npm_tag})..."
|
|
62
|
+
npm version "${CI_COMMIT_TAG}" --no-git-tag-version --allow-same-version
|
|
63
|
+
npm publish --provenance --access public --tag "${npm_tag}"
|
|
64
|
+
environment:
|
|
65
|
+
name: production
|
|
66
|
+
url: https://www.npmjs.com/package/${NPM_PACKAGE_NAME}
|
|
67
|
+
|
|
68
|
+
# RELEASE
|
|
69
|
+
# ================
|
|
70
|
+
js:release:
|
|
71
|
+
extends: .js:base
|
|
72
|
+
stage: release
|
|
73
|
+
image: ${RELEASE_CLI_IMAGE}
|
|
74
|
+
rules:
|
|
75
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
76
|
+
when: never
|
|
77
|
+
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
78
|
+
before_script:
|
|
79
|
+
- apk add --no-cache bash git jq
|
|
80
|
+
- git config --global --add safe.directory '*'
|
|
81
|
+
- git config --global user.name "GitLab CI"
|
|
82
|
+
- git config --global user.email "ci@gitlab.com"
|
|
83
|
+
script:
|
|
84
|
+
- |
|
|
85
|
+
# Tags are listed newest first, with or without the old "v" prefix (v2.1.0 then 2.2.0)
|
|
86
|
+
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 "")
|
|
87
|
+
if [[ -n "$PREVIOUS_TAG" && "$PREVIOUS_TAG" != "$CI_COMMIT_TAG" ]]; then
|
|
88
|
+
COMMITS=$(git log --pretty=format:"- %s" "${PREVIOUS_TAG}..${CI_COMMIT_TAG}" | head -20)
|
|
89
|
+
else
|
|
90
|
+
COMMITS="- Initial release"
|
|
91
|
+
fi
|
|
92
|
+
cat > release_notes.md << NOTES
|
|
93
|
+
## ${CI_COMMIT_TAG}
|
|
94
|
+
|
|
95
|
+
${COMMITS}
|
|
96
|
+
NOTES
|
|
97
|
+
release-cli create \
|
|
98
|
+
--tag-name "${CI_COMMIT_TAG}" \
|
|
99
|
+
--name "Release ${CI_COMMIT_TAG}" \
|
|
100
|
+
--description "$(cat release_notes.md)" \
|
|
101
|
+
--assets-link "{\"name\":\"npm\",\"url\":\"https://www.npmjs.com/package/${NPM_PACKAGE_NAME}/v/${CI_COMMIT_TAG}\"}"
|
|
102
|
+
artifacts:
|
|
103
|
+
paths:
|
|
104
|
+
- release_notes.md
|
|
105
|
+
expire_in: 1 year
|
|
106
|
+
|
|
107
|
+
# DOCUMENTATION
|
|
108
|
+
# ================
|
|
109
|
+
# The documentation site (GitLab Pages): every released version, each built from its own tag, and next, with a version
|
|
110
|
+
# selector. See docs/scripts/publish.sh in the project. It comes with the release: a tag is always a release of main, and
|
|
111
|
+
# nothing is published if the publication failed. The dependencies are the ones installed once by js:install.
|
|
112
|
+
# A project without docs/scripts/publish.sh has no site.
|
|
113
|
+
pages:
|
|
114
|
+
extends:
|
|
115
|
+
- .js:base
|
|
116
|
+
- .js:cache
|
|
117
|
+
stage: release
|
|
118
|
+
image: ${NODE_IMAGE}
|
|
119
|
+
needs:
|
|
120
|
+
- job: js:install
|
|
121
|
+
- job: js:publish
|
|
122
|
+
variables:
|
|
123
|
+
GIT_DEPTH: 0
|
|
124
|
+
before_script:
|
|
125
|
+
- node --version
|
|
126
|
+
script:
|
|
127
|
+
- bash docs/scripts/publish.sh
|
|
128
|
+
# The next jobs of the runner must not find (and lint) the docs dependencies or what they generate.
|
|
129
|
+
after_script:
|
|
130
|
+
- rm -rf docs/node_modules docs/.vitepress/dist docs/.vitepress/cache
|
|
131
|
+
- git clean -fdXq docs || true
|
|
132
|
+
artifacts:
|
|
133
|
+
paths:
|
|
134
|
+
- public
|
|
135
|
+
expire_in: 1 week
|
|
136
|
+
rules:
|
|
137
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
138
|
+
when: never
|
|
139
|
+
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
140
|
+
exists:
|
|
141
|
+
- docs/scripts/publish.sh
|
|
142
|
+
|
|
143
|
+
# CASCADE
|
|
144
|
+
# ================
|
|
145
|
+
# After the publication, start the update of the projects that use this package (only if the project has a cascade).
|
|
146
|
+
deps:cascade:
|
|
147
|
+
extends: .js:base
|
|
148
|
+
stage: release
|
|
149
|
+
image: ${NODE_IMAGE}
|
|
150
|
+
needs:
|
|
151
|
+
- job: js:publish
|
|
152
|
+
script:
|
|
153
|
+
- '[ -d node_modules ] || npm ci --no-audit --no-fund'
|
|
154
|
+
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" cascade
|
|
155
|
+
rules:
|
|
156
|
+
- if: $CI_COMMIT_TAG =~ $VERSION_TAG_REGEX
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# JS PIPELINE - INSTALL, VALIDATE, QUALITY AND TEST
|
|
2
|
+
# ================
|
|
3
|
+
# The jobs that every JS project runs, a package or an application.
|
|
4
|
+
# Included by pipeline-js-package.yml and pipeline-js-app.yml.
|
|
5
|
+
|
|
6
|
+
# INSTALL
|
|
7
|
+
# ================
|
|
8
|
+
js:install:
|
|
9
|
+
extends:
|
|
10
|
+
- .js:base
|
|
11
|
+
- .js:cache-push
|
|
12
|
+
- .js:rules
|
|
13
|
+
stage: install
|
|
14
|
+
image: ${NODE_IMAGE}
|
|
15
|
+
script:
|
|
16
|
+
- npm ci --cache .npm --prefer-offline
|
|
17
|
+
- |
|
|
18
|
+
if [ -f /lib/ld-musl-x86_64.so.1 ]; then
|
|
19
|
+
npm install --no-save @oxc-resolver/binding-linux-x64-musl @rollup/rollup-linux-x64-musl
|
|
20
|
+
fi
|
|
21
|
+
artifacts:
|
|
22
|
+
paths:
|
|
23
|
+
- node_modules/
|
|
24
|
+
expire_in: 1 hour
|
|
25
|
+
|
|
26
|
+
# VALIDATE
|
|
27
|
+
# ================
|
|
28
|
+
js:validate:markdownlint:
|
|
29
|
+
extends:
|
|
30
|
+
- .js:base
|
|
31
|
+
- .js:cache
|
|
32
|
+
- .js:rules
|
|
33
|
+
stage: validate
|
|
34
|
+
image: ${NODE_IMAGE}
|
|
35
|
+
script:
|
|
36
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/markdownlint.sh"
|
|
37
|
+
|
|
38
|
+
js:validate:shellcheck:
|
|
39
|
+
extends:
|
|
40
|
+
- .js:base
|
|
41
|
+
- .js:rules
|
|
42
|
+
stage: validate
|
|
43
|
+
image: ${SHELLCHECK_IMAGE}
|
|
44
|
+
before_script:
|
|
45
|
+
- apk add --no-cache bash
|
|
46
|
+
script:
|
|
47
|
+
- |
|
|
48
|
+
if [[ -d scripts/ ]]; then
|
|
49
|
+
bash "$JS_DEV_TOOLS_SCRIPTS/validate-shellcheck.sh"
|
|
50
|
+
else
|
|
51
|
+
echo "No scripts/ directory found - skipping ShellCheck"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# QUALITY
|
|
55
|
+
# ================
|
|
56
|
+
js:quality:lint:
|
|
57
|
+
extends:
|
|
58
|
+
- .js:node
|
|
59
|
+
- .js:rules
|
|
60
|
+
stage: quality
|
|
61
|
+
script:
|
|
62
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/eslint.sh"
|
|
63
|
+
artifacts:
|
|
64
|
+
reports:
|
|
65
|
+
junit: build/reports/eslint.xml
|
|
66
|
+
paths:
|
|
67
|
+
- build/reports/
|
|
68
|
+
expire_in: 1 week
|
|
69
|
+
when: always
|
|
70
|
+
|
|
71
|
+
js:quality:format:
|
|
72
|
+
extends:
|
|
73
|
+
- .js:node
|
|
74
|
+
- .js:rules
|
|
75
|
+
stage: quality
|
|
76
|
+
script:
|
|
77
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/prettier.sh"
|
|
78
|
+
|
|
79
|
+
js:quality:stylelint:
|
|
80
|
+
extends:
|
|
81
|
+
- .js:node
|
|
82
|
+
- .js:rules
|
|
83
|
+
stage: quality
|
|
84
|
+
script:
|
|
85
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/stylelint.sh"
|
|
86
|
+
|
|
87
|
+
js:quality:typecheck:
|
|
88
|
+
extends:
|
|
89
|
+
- .js:node
|
|
90
|
+
- .js:rules
|
|
91
|
+
stage: quality
|
|
92
|
+
script:
|
|
93
|
+
- |
|
|
94
|
+
if [ -f tsconfig.json ] && [ -f node_modules/.bin/tsc ]; then
|
|
95
|
+
bash "$JS_DEV_TOOLS_SCRIPTS/typecheck.sh"
|
|
96
|
+
else
|
|
97
|
+
echo "TypeScript not configured - skipping (add tsconfig.json + typescript to devDependencies)"
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
js:quality:knip:
|
|
101
|
+
extends:
|
|
102
|
+
- .js:node
|
|
103
|
+
- .js:rules
|
|
104
|
+
stage: quality
|
|
105
|
+
script:
|
|
106
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/knip.sh"
|
|
107
|
+
|
|
108
|
+
js:quality:bats:
|
|
109
|
+
extends:
|
|
110
|
+
- .js:base
|
|
111
|
+
- .js:cache
|
|
112
|
+
- .js:rules
|
|
113
|
+
stage: quality
|
|
114
|
+
image: ${ALPINE_IMAGE}
|
|
115
|
+
before_script:
|
|
116
|
+
- apk add --no-cache bash bats git
|
|
117
|
+
script:
|
|
118
|
+
- |
|
|
119
|
+
if [[ -d tests/bats ]]; then
|
|
120
|
+
bats tests/bats --recursive
|
|
121
|
+
else
|
|
122
|
+
echo "No BATS tests found - skipping"
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
js:quality:outdated:
|
|
126
|
+
extends: .js:node
|
|
127
|
+
stage: quality
|
|
128
|
+
rules:
|
|
129
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
130
|
+
when: never
|
|
131
|
+
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
132
|
+
script:
|
|
133
|
+
- bash "$JS_DEV_TOOLS_SCRIPTS/outdated.sh"
|
|
134
|
+
artifacts:
|
|
135
|
+
paths:
|
|
136
|
+
- build/reports/npm-outdated.json
|
|
137
|
+
expire_in: 1 week
|
|
138
|
+
when: always
|
|
139
|
+
|
|
140
|
+
# TEST
|
|
141
|
+
# ================
|
|
142
|
+
js:test:
|
|
143
|
+
extends:
|
|
144
|
+
- .js:base
|
|
145
|
+
- .js:cache
|
|
146
|
+
- .js:rules
|
|
147
|
+
stage: test
|
|
148
|
+
image: ${NODE_TEST_IMAGE}
|
|
149
|
+
script:
|
|
150
|
+
- CI=true bash "$JS_DEV_TOOLS_SCRIPTS/test.sh"
|
|
151
|
+
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
|
|
152
|
+
artifacts:
|
|
153
|
+
reports:
|
|
154
|
+
junit: coverage/junit.xml
|
|
155
|
+
coverage_report:
|
|
156
|
+
coverage_format: cobertura
|
|
157
|
+
path: coverage/cobertura-coverage.xml
|
|
158
|
+
paths:
|
|
159
|
+
- coverage/
|
|
160
|
+
expire_in: 1 week
|
|
161
|
+
when: always
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# JS PIPELINE - SECURITY
|
|
2
|
+
# ================
|
|
3
|
+
# The secret detection of GitLab and the check of the format of a tag.
|
|
4
|
+
# Included by pipeline-js-package.yml and pipeline-js-app.yml.
|
|
5
|
+
|
|
6
|
+
include:
|
|
7
|
+
- template: Jobs/Secret-Detection.gitlab-ci.yml
|
|
8
|
+
|
|
9
|
+
secret_detection:
|
|
10
|
+
stage: security
|
|
11
|
+
rules:
|
|
12
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
13
|
+
when: never
|
|
14
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
15
|
+
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
16
|
+
|
|
17
|
+
# A tag whose format is not the one of VERSION_TAG_REGEX (group variable) fails here,
|
|
18
|
+
# and the jobs that publish do not run for it.
|
|
19
|
+
js:tag-format:
|
|
20
|
+
extends: .js:base
|
|
21
|
+
stage: security
|
|
22
|
+
image: ${ALPINE_IMAGE}
|
|
23
|
+
rules:
|
|
24
|
+
- if: $UPDATE_DEPENDENCIES == "true"
|
|
25
|
+
when: never
|
|
26
|
+
- if: $CI_COMMIT_TAG
|
|
27
|
+
script:
|
|
28
|
+
- |
|
|
29
|
+
regex="${VERSION_TAG_REGEX:-}"
|
|
30
|
+
regex="${regex#/}"
|
|
31
|
+
regex="${regex%/}"
|
|
32
|
+
if [ -z "$regex" ]; then
|
|
33
|
+
echo "ERROR: VERSION_TAG_REGEX is not set. It is a variable of the zairakai group."
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
if ! printf '%s\n' "$CI_COMMIT_TAG" | grep -Eq "$regex"; then
|
|
37
|
+
echo "ERROR: the tag \"$CI_COMMIT_TAG\" does not match $VERSION_TAG_REGEX (X.Y.Z or X.Y.Z-prerelease)."
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
echo "Tag $CI_COMMIT_TAG: format OK"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# JS PIPELINE - AUTOMATIC UPDATES
|
|
2
|
+
# ================
|
|
3
|
+
# See the handbook, policies/dependency-management.md. The exceptions of a project live in .dependency-update.json.
|
|
4
|
+
# The group variable GITLAB_TOKEN (protected, so these jobs run on main, develop and the tags) opens the merge requests,
|
|
5
|
+
# merges them and creates the tags. The pipeline of each merge request is the gate: nothing is tested by these jobs.
|
|
6
|
+
# Included by pipeline-js-package.yml and pipeline-js-app.yml. deps:cascade, which needs the publication, is in publish.yml.
|
|
7
|
+
|
|
8
|
+
# A weekly schedule (or a pipeline started by the cascade) with UPDATE_DEPENDENCIES=true prepares the update.
|
|
9
|
+
deps:update:
|
|
10
|
+
extends: .js:base
|
|
11
|
+
stage: install
|
|
12
|
+
image: ${NODE_UPDATE_IMAGE}
|
|
13
|
+
needs: []
|
|
14
|
+
script:
|
|
15
|
+
- node --version
|
|
16
|
+
- '[ -d node_modules ] || npm ci --no-audit --no-fund'
|
|
17
|
+
- '[ "${JS_DEV_TOOLS_SCRIPTS}" = "scripts" ] || npm install --no-save --no-audit --no-fund "@zairakai/js-dev-tools@latest"'
|
|
18
|
+
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" update
|
|
19
|
+
rules:
|
|
20
|
+
- if: $UPDATE_DEPENDENCIES == "true" && $AUDIT_DEPENDENCIES != "true" && $CI_COMMIT_BRANCH == "develop"
|
|
21
|
+
|
|
22
|
+
# A daily schedule with UPDATE_DEPENDENCIES=true and AUDIT_DEPENDENCIES=true looks for security advisories: one issue per
|
|
23
|
+
# advisory (ntfy alert, closed when it is gone) and, with the group variable AUTO_FIX=true, an update started to fix it.
|
|
24
|
+
# The token FRESHNESS_TOKEN of the group (else GITLAB_TOKEN) opens the issues and starts the update; NTFY_URL is the alert.
|
|
25
|
+
deps:audit:
|
|
26
|
+
extends: .js:base
|
|
27
|
+
stage: install
|
|
28
|
+
image: ${NODE_UPDATE_IMAGE}
|
|
29
|
+
needs: []
|
|
30
|
+
script:
|
|
31
|
+
- node --version
|
|
32
|
+
- '[ -d node_modules ] || npm ci --no-audit --no-fund'
|
|
33
|
+
- '[ "${JS_DEV_TOOLS_SCRIPTS}" = "scripts" ] || npm install --no-save --no-audit --no-fund "@zairakai/js-dev-tools@latest"'
|
|
34
|
+
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" audit
|
|
35
|
+
rules:
|
|
36
|
+
- if: $UPDATE_DEPENDENCIES == "true" && $AUDIT_DEPENDENCIES == "true" && $CI_COMMIT_BRANCH == "develop"
|
|
37
|
+
|
|
38
|
+
# After the merge of an update into develop, bring develop into main.
|
|
39
|
+
deps:release:
|
|
40
|
+
extends: .js:base
|
|
41
|
+
stage: release
|
|
42
|
+
image: ${NODE_IMAGE}
|
|
43
|
+
script:
|
|
44
|
+
- '[ -d node_modules ] || npm ci --no-audit --no-fund'
|
|
45
|
+
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" release
|
|
46
|
+
rules:
|
|
47
|
+
- if: $CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_MESSAGE =~ /chore\/update-dependencies/
|
|
48
|
+
|
|
49
|
+
# After the merge of an update into main, tag it when a published range changed. The tag starts the publication.
|
|
50
|
+
deps:tag:
|
|
51
|
+
extends: .js:base
|
|
52
|
+
stage: release
|
|
53
|
+
image: ${NODE_UPDATE_IMAGE}
|
|
54
|
+
variables:
|
|
55
|
+
GIT_DEPTH: 0
|
|
56
|
+
script:
|
|
57
|
+
- '[ -d node_modules ] || npm ci --no-audit --no-fund'
|
|
58
|
+
- node "${JS_DEV_TOOLS_SCRIPTS}/update-dependencies.mjs" tag
|
|
59
|
+
rules:
|
|
60
|
+
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
|