@w5s/mrm-preset 1.0.0-alpha.1

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.
Files changed (51) hide show
  1. package/.eslintignore +1 -0
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +56 -0
  4. package/bootstrap/README.md +5 -0
  5. package/bootstrap/index.js +97 -0
  6. package/ci/_gitlab/AutoDevops.gitlab-ci.yml +77 -0
  7. package/ci/_gitlab/AutoDevopsInclude.gitlab-ci.yml +251 -0
  8. package/ci/_gitlab/README.md +20 -0
  9. package/ci/_gitlab/Renovate.gitlab-ci.yml +30 -0
  10. package/ci/gitlab.js +38 -0
  11. package/ci/index.js +14 -0
  12. package/commitlint/index.js +40 -0
  13. package/config.json +20 -0
  14. package/contributing/index.js +26 -0
  15. package/contributing/templates/CODE_OF_CONDUCT.md +134 -0
  16. package/core/block.js +77 -0
  17. package/core/commitlint.js +39 -0
  18. package/core/cspell.js +66 -0
  19. package/core/eslint.js +22 -0
  20. package/core/file.js +29 -0
  21. package/core/git.js +73 -0
  22. package/core/githooks.js +71 -0
  23. package/core/gitlabCI.js +8 -0
  24. package/core/jest.js +105 -0
  25. package/core/jsonFile.js +65 -0
  26. package/core/lintStaged.js +36 -0
  27. package/core/npm.js +271 -0
  28. package/core/pkg.js +97 -0
  29. package/core/project.js +58 -0
  30. package/core/semanticRelease.js +43 -0
  31. package/core/typedoc.js +82 -0
  32. package/core/vscode.js +92 -0
  33. package/core/workspace.js +6 -0
  34. package/cspell/index.js +38 -0
  35. package/editorconfig/index.js +107 -0
  36. package/eslint/index.js +127 -0
  37. package/githooks/index.js +62 -0
  38. package/githooks/templates/CODEOWNERS +4 -0
  39. package/gitignore/index.js +25 -0
  40. package/gitignore/template.js +145 -0
  41. package/jest/index.js +19 -0
  42. package/lang/.eslintrc.json +8 -0
  43. package/lang/index.js +143 -0
  44. package/lang/templates/index.spec.ts +7 -0
  45. package/lang/templates/index.ts +6 -0
  46. package/package.json +48 -0
  47. package/postconfigure/index.js +17 -0
  48. package/project/index.js +232 -0
  49. package/release/index.js +29 -0
  50. package/renovate/index.js +61 -0
  51. package/tsconfig.json +13 -0
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ _tester
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # 1.0.0-alpha.1 (2022-02-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * correct generate cspell.json ([e638b75](https://github.com/w5s/project-config/commit/e638b75ead5d3ffd34b0c74b95b237d29b542406))
12
+
13
+
14
+ ### Features
15
+
16
+ * add cspell check on lint-staged in mrm ([d8a744f](https://github.com/w5s/project-config/commit/d8a744f1f297c2308cd15ce1f19958f9302eee5d))
17
+ * add mrm-preset package ([1409046](https://github.com/w5s/project-config/commit/1409046e772755148f9885ce39c8f86afef4e50d))
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=# W5s Mrm Preset _(${name})_) -->
2
+ # W5s Mrm Preset _(@w5s/mrm-preset)_
3
+ <!-- AUTO-GENERATED-CONTENT:END -->
4
+
5
+ [![NPM Version][package-version-svg]][package-url]
6
+ [![License][license-image]][license-url]
7
+
8
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=> ${description}&unknownTxt= ) -->
9
+ > Mrm configuration presets
10
+ <!-- AUTO-GENERATED-CONTENT:END -->
11
+
12
+ ## Getting Started - App Installation
13
+
14
+ ## Usage
15
+
16
+ ### 1. Install Preset
17
+
18
+ Initialize your project using this command :
19
+
20
+ ```bash
21
+ # from the root of your project
22
+ npm exec -p mrm -p @w5s/mrm-preset -- mrm bootstrap --preset @w5s/mrm-preset
23
+ ```
24
+
25
+ This will install in `package.json` the npm scripts
26
+
27
+ - `mrm` : alias to mrm using `@w5s/mrm-preset` by default
28
+
29
+ - `configure` : runs `npm run mrm -- configure`
30
+
31
+ ### 2. Configure project
32
+
33
+ After initialization and after any upgrade of `@w5s/mrm-preset`
34
+
35
+ ```bash
36
+ # from the root of your project
37
+ npm run configure
38
+ ```
39
+
40
+ ## License
41
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[${license}][license-url] © ${author}) -->
42
+ [MIT][license-url] © Julien Polo <julien.polo@gmail.com>
43
+ <!-- AUTO-GENERATED-CONTENT:END -->
44
+
45
+ <!-- VARIABLES -->
46
+
47
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square) -->
48
+ [package-version-svg]: https://img.shields.io/npm/v/@w5s/mrm-preset.svg?style=flat-square
49
+ <!-- AUTO-GENERATED-CONTENT:END -->
50
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}) -->
51
+ [package-url]: https://www.npmjs.com/package/@w5s/mrm-preset
52
+ <!-- AUTO-GENERATED-CONTENT:END -->
53
+ <!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square) -->
54
+ [license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
55
+ <!-- AUTO-GENERATED-CONTENT:END -->
56
+ [license-url]: ../../LICENSE
@@ -0,0 +1,5 @@
1
+ # Bootstrap task
2
+
3
+ ```bash
4
+ npm exec -p mrm -p @w5s/mrm-preset -- mrm bootstrap --preset @w5s/mrm-preset
5
+ ```
@@ -0,0 +1,97 @@
1
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
2
+ const path = require('path');
3
+ const { packageJson, file } = require('mrm-core');
4
+ const npm = require('../core/npm');
5
+ const pkg = require('../core/pkg');
6
+
7
+ /**
8
+ * @param {{
9
+ * mrmPreset: string,
10
+ * mrmTask: string,
11
+ * packageArchetype: 'application'|'library'|'workspace',
12
+ * packageManager: 'npm'|'yarn'
13
+ * }} config
14
+ * @returns {void}
15
+ */
16
+ function task({ mrmPreset, mrmTask, packageArchetype, packageManager }) {
17
+ /**
18
+ * setup package.json from following object
19
+ */
20
+
21
+ const packageFile = packageJson({
22
+ name: path.basename(process.cwd()),
23
+ version: '1.0.0-alpha.0',
24
+ private: true,
25
+ license: 'PRIVATE',
26
+ description: '',
27
+ });
28
+
29
+ packageFile.merge({
30
+ scripts: {
31
+ configure: `npm run mrm -- ${mrmTask}`,
32
+ mrm: `mrm --preset ${mrmPreset}`,
33
+ },
34
+ });
35
+ pkg.value(packageFile, {
36
+ path: 'packageManager',
37
+ state: 'present',
38
+ update: packageManager,
39
+ default: () => {
40
+ if (file('yarn.lock').exists()) {
41
+ return 'yarn';
42
+ }
43
+
44
+ // return 'npm';
45
+ return undefined;
46
+ },
47
+ });
48
+ pkg.value(packageFile, {
49
+ path: 'mrmConfig.packageArchetype',
50
+ state: 'present',
51
+ update: packageArchetype,
52
+ default: () => {
53
+ if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
54
+ return 'workspace';
55
+ }
56
+
57
+ return 'library';
58
+ },
59
+ });
60
+ packageFile.save();
61
+
62
+ npm.dependency({
63
+ dev: true,
64
+ name: ['mrm', mrmPreset],
65
+ yarn: packageManager === 'yarn',
66
+ state: 'present',
67
+ });
68
+ }
69
+
70
+ task.description = 'Bootstrap a new project.';
71
+ // TODO: parameters to improve with strict choices and description (see Inquirer.js)
72
+ task.parameters = {
73
+ mrmPreset: {
74
+ default: '@w5s/mrm-preset',
75
+ message: 'Default MRM preset name ?',
76
+ type: 'input',
77
+ },
78
+ mrmTask: {
79
+ default: 'configure',
80
+ message: 'Default MRM task name ?',
81
+ type: 'input',
82
+ },
83
+ packageArchetype: {
84
+ choices: ['library', 'application', 'workspace'],
85
+ message: 'What Archetype of package ?',
86
+ name: 'packageArchetype',
87
+ type: 'input',
88
+ },
89
+ packageManager: {
90
+ default: 'yarn',
91
+ choices: ['yarn', 'npm'],
92
+ message: 'Which default package manager ?',
93
+ name: 'packageManager',
94
+ type: 'input',
95
+ },
96
+ };
97
+ module.exports = task;
@@ -0,0 +1,77 @@
1
+ ##
2
+ # Follow the following standards
3
+ #
4
+ # @ref https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
5
+ # @ref https://github.com/SocialGouv/gitlab-ci-yml/
6
+ #
7
+ include:
8
+ - /.gitlab/AutoDevopsInclude.gitlab-ci.yml
9
+
10
+ workflow:
11
+ rules:
12
+ # Skip GitHub pull requests pipelines
13
+ - if: $CI_PIPELINE_SOURCE == 'external_pull_request_event'
14
+ when: never
15
+ # Otherwise include the job and set to run normally
16
+ - when: always
17
+
18
+ stages:
19
+ - prepare
20
+ - build
21
+ - code_quality
22
+ - registration
23
+ - release
24
+ - deploy # Dummy stage, prefer staging, canary and production
25
+ - staging
26
+ - canary
27
+ - production
28
+ - incremental rollout 10%
29
+ - incremental rollout 25%
30
+ - incremental rollout 50%
31
+ - incremental rollout 100%
32
+ - performance
33
+ - cleanup
34
+
35
+ variables:
36
+ GIT_STRATEGY: fetch
37
+ GIT_DEPTH: 5
38
+
39
+ #
40
+ # Jobs
41
+ #
42
+ install:
43
+ extends: .autodevops_install
44
+
45
+ lint:
46
+ extends: .autodevops_lint
47
+
48
+ test:
49
+ extends: .autodevops_test
50
+
51
+ build:
52
+ extends: .autodevops_build
53
+
54
+ release:
55
+ extends: .autodevops_trigger_release
56
+
57
+ # register_image:
58
+ # extends: .autodevops_register_image
59
+
60
+ renovate:
61
+ extends: .autodevops_renovate
62
+
63
+ pages:
64
+ extends: .autodevops_pages
65
+
66
+ code_analysis:
67
+ extends:
68
+ - .autodevops_code_analysis
69
+ variables:
70
+ CODE_ANALYSIS_HOUR: 7 # 7h UTC => 9h Paris
71
+ # CODE_ANALYSIS_DISABLED: "🛑"
72
+
73
+ # deploy_production:
74
+ # extends:
75
+ # - .autodevops_trigger_deploy
76
+ # variables:
77
+ # DEPLOY_ENVIRONMENT: production
@@ -0,0 +1,251 @@
1
+ #
2
+ include:
3
+ - /.gitlab/Renovate.gitlab-ci.yml
4
+
5
+ # Default variables
6
+ variables:
7
+
8
+
9
+ # To activate the auto release
10
+ AUTO_DEVOPS_QUALITY_WHEN: 'always' # 'always'|'never'
11
+ AUTO_DEVOPS_TEST_WHEN: 'always' # 'always'|'never'
12
+ AUTO_DEVOPS_RELEASE_WHEN: 'manual' # 'on_success'|'manual'|'never'
13
+ AUTO_DEVOPS_DEPLOY_ALLOW: 'tag' # 'tag'|'any'
14
+ AUTO_DEVOPS_DEPLOY_WHEN: 'manual' # 'on_success'|'manual'|'never'
15
+
16
+ # Renovate variable
17
+ # RENOVATE_DISABLED: "🛑"
18
+
19
+ ##
20
+ # Contextual variables
21
+ ##
22
+ # DEPLOY_ENVIRONMENT: production,staging,...
23
+ # RENOVATE: true|false
24
+
25
+ #
26
+ # AutoDevops jobs
27
+ #
28
+
29
+ # Trait to refactor common reusable rules
30
+ .autodevops_base_rules:
31
+ rules:
32
+ - &autodevops_schedule_skip_rule
33
+ if: '$CI_PIPELINE_SOURCE == "schedule"'
34
+ when: never
35
+ - &autodevops_renovate_skip_rule
36
+ if: "$RENOVATE"
37
+ when: never
38
+ - &autodevops_default_branch_only_rule
39
+ if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
40
+ when: never
41
+ - when: on_success
42
+
43
+ ##
44
+ # Generic trait for a trigger button for release stage
45
+ #
46
+ .autodevops_trigger_release:
47
+ stage: release
48
+ extends:
49
+ - .autodevops_node_install
50
+ - .autodevops_node_image
51
+ rules:
52
+ - <<: *autodevops_schedule_skip_rule
53
+ - <<: *autodevops_default_branch_only_rule
54
+ - if: "$AUTO_DEVOPS_RELEASE_WHEN == 'never'"
55
+ when: never
56
+ - if: "$CI_COMMIT_TAG"
57
+ when: never
58
+ - if: $CI_COMMIT_MESSAGE =~ /chore\(release\):/
59
+ when: never
60
+ - if: "$AUTO_DEVOPS_RELEASE_WHEN != 'manual'"
61
+ when: on_success
62
+ - when: manual
63
+ needs:
64
+ - job: install
65
+ artifacts: true
66
+ - job: build
67
+ artifacts: true
68
+ # Blocking job : https://gitlab.com/gitlab-org/gitlab/-/issues/17768#note_214977686
69
+ allow_failure: false
70
+ script:
71
+ - git config --global user.email "${CI_EMAIL}"
72
+ - git config --global user.name "${CI_USERNAME}"
73
+ - git remote set-url origin "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git"
74
+ - git checkout -B "$CI_COMMIT_REF_NAME" "$CI_COMMIT_SHA"
75
+ - npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
76
+ - npm run release
77
+
78
+ ##
79
+ # Generic trait for a trigger button for deploy stage.
80
+ # Use DEPLOY_ENVIRONMENT variable to choose environment
81
+ #
82
+ # Example:
83
+ # .my_job:
84
+ # extends: .autodevops_trigger_deploy
85
+ # variables:
86
+ # DEPLOY_ENVIRONMENT: "my-prod"
87
+ #
88
+ .autodevops_trigger_deploy:
89
+ stage: deploy
90
+ rules:
91
+ - <<: *autodevops_schedule_skip_rule
92
+ # Tag based deployment
93
+ - if: "$AUTO_DEVOPS_DEPLOY_WHEN == 'never'"
94
+ when: never
95
+ - if: $AUTO_DEVOPS_DEPLOY_ALLOW == 'tag' && $CI_COMMIT_TAG == null
96
+ when: never
97
+ - if: $AUTO_DEVOPS_DEPLOY_ALLOW == 'tag' && $CI_COMMIT_TAG != null && $AUTO_DEVOPS_DEPLOY_WHEN == 'manual'
98
+ when: manual
99
+ - if: $AUTO_DEVOPS_DEPLOY_ALLOW == 'tag' && $CI_COMMIT_TAG != null && $AUTO_DEVOPS_DEPLOY_WHEN == 'on_success'
100
+ when: on_success
101
+ # Default branch based deployment
102
+ - <<: *autodevops_default_branch_only_rule
103
+ - if: $AUTO_DEVOPS_DEPLOY_WHEN != 'manual'
104
+ when: on_success
105
+ - when: manual
106
+
107
+ .autodevops_install:
108
+ stage: prepare
109
+ extends:
110
+ - .autodevops_node_install
111
+ interruptible: true
112
+ rules:
113
+ - <<: *autodevops_schedule_skip_rule
114
+ - when: on_success
115
+
116
+ .autodevops_lint:
117
+ stage: code_quality
118
+ rules:
119
+ - <<: *autodevops_schedule_skip_rule
120
+ - if: "$AUTO_DEVOPS_QUALITY_WHEN == 'never'"
121
+ when: never
122
+ - when: always
123
+ extends:
124
+ - .autodevops_node_install
125
+ - .autodevops_node_image
126
+ needs:
127
+ - job: install
128
+ artifacts: true
129
+ - job: build
130
+ artifacts: true
131
+ script:
132
+ - yarn lint
133
+
134
+ .autodevops_test:
135
+ stage: code_quality
136
+ rules:
137
+ - <<: *autodevops_schedule_skip_rule
138
+ - if: "$AUTO_DEVOPS_TEST_WHEN == 'never'"
139
+ when: never
140
+ - when: always
141
+ extends:
142
+ - .autodevops_node_install
143
+ - .autodevops_node_image
144
+ needs:
145
+ - job: install
146
+ artifacts: true
147
+ - job: build
148
+ artifacts: true
149
+ script:
150
+ - yarn test
151
+
152
+ .autodevops_build:
153
+ stage: build
154
+ extends:
155
+ - .autodevops_node_build
156
+ rules:
157
+ - <<: *autodevops_schedule_skip_rule
158
+ - when: on_success
159
+ needs:
160
+ - job: install
161
+ artifacts: true
162
+
163
+ .autodevops_pages:
164
+ extends:
165
+ - .autodevops_node_docs
166
+ - .autodevops_trigger_deploy
167
+ artifacts:
168
+ paths:
169
+ - public
170
+
171
+ .autodevops_code_analysis:
172
+ stage: code_quality
173
+ extends:
174
+ - .autodevops_node_install
175
+ variables:
176
+ CODE_ANALYSIS_HOUR: 7 # 7h UTC => 9h Paris
177
+ # CODE_ANALYSIS_DISABLED: "🛑"
178
+ rules:
179
+ - if: "$CODE_ANALYSIS_DISABLED"
180
+ when: never
181
+ - if: '$CI_PIPELINE_SOURCE == "schedule"'
182
+ when: always
183
+ - when: never
184
+ script:
185
+ - >
186
+ if [ `date +%H` -eq $CODE_ANALYSIS_HOUR ]; then
187
+ npm run code-analysis;
188
+ else
189
+ echo "Code Analysis skipped H=$(date +%H)";
190
+ fi
191
+
192
+ # .autodevops_register_image:
193
+ # extends:
194
+ # - .base_register_stage
195
+ # stage: registration
196
+ # needs:
197
+ # - job: Build
198
+ # artifacts: true
199
+ # variables:
200
+ # CONTEXT: .
201
+ # IMAGE_NAME: $CI_REGISTRY_IMAGE
202
+
203
+ .autodevops_node_image:
204
+ image: node:lts-alpine
205
+
206
+ .autodevops_node_install:
207
+ extends:
208
+ - .autodevops_node_image
209
+ before_script:
210
+ - yarn install --frozen-lockfile --prefer-offline
211
+ script:
212
+ - echo 'Installation Successful'
213
+ retry:
214
+ max: 2
215
+ when:
216
+ - runner_system_failure
217
+ - stuck_or_timeout_failure
218
+
219
+ .autodevops_node_build:
220
+ extends:
221
+ - .autodevops_node_image
222
+ - .autodevops_node_install
223
+ script:
224
+ - npm run build
225
+ artifacts:
226
+ expire_in: 1 week
227
+ paths:
228
+ - dist
229
+ - "packages/*/dist"
230
+ - lib
231
+ - "packages/*/lib"
232
+ - node_modules
233
+
234
+ .autodevops_node_docs:
235
+ extends:
236
+ - .autodevops_node_image
237
+ - .autodevops_node_install
238
+ script:
239
+ # We use NPM because supports `--if-present`
240
+ - npm run docs --if-present
241
+
242
+ .autodevops_renovate:
243
+ stage: prepare
244
+ rules:
245
+ - if: "$RENOVATE_DISABLED"
246
+ when: never
247
+ - if: "$RENOVATE"
248
+ when: always
249
+ - when: never
250
+ extends:
251
+ - .renovate
@@ -0,0 +1,20 @@
1
+ # Documentation
2
+
3
+ ## Setup Renovate
4
+
5
+ 1. Open the project on gitlab website
6
+ 2. Go to CI/CD > Schedules
7
+ 3. Configure job
8
+ * Set `Interval pattern` to `0 * * * *`
9
+ * Add variables `RENOVATE` to `ON`
10
+
11
+ ## Setup NPM Release
12
+
13
+ 1. Open the project on gitlab website -OR- open the organization for global settings
14
+ 2. Configure GitLab CI environment variables to allow script to push (tags for example)
15
+ 1. Set `CI_EMAIL` to a valid email.
16
+ 2. Set `CI_USERNAME` to a valid name.
17
+ 3. Configure GitLab CI environment variables to allow publishing on NPM registry
18
+ 1. Open [https://npmjs.com](https://npmjs.com)
19
+ 2. Go to the "Access token" section and generate a new 'Read & Write Token'
20
+ 3. Add the `NPM_TOKEN` environment variable containing the created token
@@ -0,0 +1,30 @@
1
+ # https://fotoallerlei.com/blog/post/2020/automatic-dependency-updates-with-renovate-and-gitlab/post
2
+ .renovate:
3
+ variables:
4
+ RENOVATE_GIT_AUTHOR: "${GITLAB_USER_NAME} <${GITLAB_USER_EMAIL}>"
5
+ RENOVATE_DRY_RUN: "false"
6
+ RENOVATE_LOG_LEVEL: "debug"
7
+ RENOVATE_ALLOWED_POST_UPGRADE: "^pod ,^yarn "
8
+ # RENOVATE_DISABLED: "🛑"
9
+ rules:
10
+ - if: "$RENOVATE_DISABLED"
11
+ when: never
12
+ - if: '$CI_PIPELINE_SOURCE == "schedule"'
13
+ when: always
14
+ - when: never
15
+ image:
16
+ name: renovate/renovate
17
+ entrypoint: [""]
18
+ script:
19
+ - >
20
+ renovate
21
+ --platform "gitlab"
22
+ --endpoint "${CI_API_V4_URL}"
23
+ --git-author "${RENOVATE_GIT_AUTHOR}"
24
+ --dry-run "${RENOVATE_DRY_RUN}"
25
+ --log-file-level "${RENOVATE_LOG_LEVEL}"
26
+ --allow-post-upgrade-command-templating
27
+ --allowed-post-upgrade-commands "${RENOVATE_ALLOWED_POST_UPGRADE}"
28
+ "${CI_PROJECT_PATH}"
29
+ tags:
30
+ - renovate
package/ci/gitlab.js ADDED
@@ -0,0 +1,38 @@
1
+ /* eslint-disable global-require, sort-keys-fix/sort-keys-fix */
2
+ const path = require('path');
3
+ const { yaml } = require('mrm-core');
4
+
5
+ /** @type {typeof import('sync-directory')['default']} */
6
+ const syncDirectory = /** @type {any} */ (require('sync-directory'));
7
+
8
+ function task() {
9
+ const gitlabCIConfig = yaml('.gitlab-ci.yml');
10
+ const gitlabCILib = '.gitlab';
11
+ const state = 'present';
12
+
13
+ if (state === 'present') {
14
+ syncDirectory(path.join(__dirname, '_gitlab'), path.resolve(gitlabCILib));
15
+ }
16
+
17
+ // Default include and stages
18
+ const autoDevopsPath = `${gitlabCILib}/AutoDevops.gitlab-ci.yml`;
19
+ const hasInclude = (/** @type {string} */ includePath) =>
20
+ gitlabCIConfig.get('include', []).some(
21
+ /**
22
+ * @param {string|{local: string}} include
23
+ */
24
+ (include) => {
25
+ return (typeof include === 'string' ? include : include.local) === includePath;
26
+ }
27
+ );
28
+ const addInclude = (/** @type {string} */ includePath) =>
29
+ gitlabCIConfig.set('include', gitlabCIConfig.get('include', []).concat([{ local: includePath }]));
30
+
31
+ if (!hasInclude(autoDevopsPath)) {
32
+ addInclude(autoDevopsPath);
33
+ }
34
+
35
+ gitlabCIConfig.save();
36
+ }
37
+
38
+ module.exports = task;
package/ci/index.js ADDED
@@ -0,0 +1,14 @@
1
+ const gitlabCI = require('../core/gitlabCI');
2
+ const gitlab = require('./gitlab');
3
+
4
+ function task() {
5
+ // check gitlab support
6
+ if (gitlabCI.isSupported()) {
7
+ gitlab();
8
+ }
9
+ }
10
+
11
+ task.description = 'Setup Continuous Integration';
12
+ task.parameters = {};
13
+
14
+ module.exports = task;
@@ -0,0 +1,40 @@
1
+ const { commitlint } = require('../core/commitlint');
2
+ const { hasGit } = require('../core/git');
3
+
4
+ /**
5
+ *
6
+ * @param {{
7
+ * commitLintPreset?: string
8
+ * }} config
9
+ */
10
+ function createCommitLint({ commitLintPreset: commitLintPresetDefault }) {
11
+ /**
12
+ *
13
+ * @param {{
14
+ * commitLintPreset: string
15
+ * }} parameters
16
+ */
17
+ function task({ commitLintPreset }) {
18
+ const gitPresent = hasGit();
19
+
20
+ commitlint({
21
+ preset: commitLintPreset,
22
+ state: gitPresent ? 'present' : 'absent',
23
+ });
24
+ }
25
+
26
+ task.description = 'Setup CommitLint';
27
+ task.parameters = {
28
+ commitLintPreset: {
29
+ default: commitLintPresetDefault,
30
+ message: 'Enter CommitLint preset name',
31
+ type: 'input',
32
+ },
33
+ };
34
+
35
+ return task;
36
+ }
37
+
38
+ module.exports = createCommitLint({
39
+ commitLintPreset: '@w5s/commitlint-config',
40
+ });
package/config.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "aliases": {
3
+ "configure": [
4
+ "gitignore",
5
+ "project",
6
+ "contributing",
7
+ "release",
8
+ "ci",
9
+ "lang",
10
+ "commitlint",
11
+ "editorconfig",
12
+ "eslint",
13
+ "cspell",
14
+ "jest",
15
+ "renovate",
16
+ "githooks",
17
+ "postconfigure"
18
+ ]
19
+ }
20
+ }