Skip to content

Commit 2027938

Browse files
committed
feat(ci-cd): initial repo setup
gh-00
0 parents  commit 2027938

25 files changed

+17090
-0
lines changed

.czferc.js

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
const types = [
2+
{value: 'feat', name: 'feat: A new feature'},
3+
{value: 'fix', name: 'fix: A bug fix'},
4+
{value: 'docs', name: 'docs: Documentation only changes'},
5+
{
6+
value: 'style',
7+
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
8+
},
9+
{
10+
value: 'refactor',
11+
name: 'refactor: A code change that neither fixes a bug nor adds a feature',
12+
},
13+
{
14+
value: 'perf',
15+
name: 'perf: A code change that improves performance',
16+
},
17+
{value: 'test', name: 'test: Adding missing tests'},
18+
{
19+
value: 'chore',
20+
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
21+
},
22+
{value: 'revert', name: 'revert: Revert to a commit'},
23+
{value: 'WIP', name: 'WIP: Work in progress'},
24+
];
25+
26+
const scopes = [
27+
{name: 'chore'},
28+
{name: 'ci-cd'},
29+
{name: 'core'},
30+
{name: 'styles'},
31+
{name: 'auth'},
32+
{name: 'theme'},
33+
{name: 'shared'},
34+
];
35+
36+
/**
37+
* @typedef {{type: string; scope: string; subject: string; body: string; isBreaking: boolean; breakingBody: string; breaking: string; isIssueAffected: boolean; issuesBody: string; issues: string;}} Answers
38+
*/
39+
40+
/** @type import('cz-format-extension').Config<Answers> */
41+
module.exports = {
42+
questions({inquirer, gitInfo}) {
43+
let migrationQuestions = getMigrationChanges(gitInfo.staged);
44+
return [
45+
{
46+
type: 'list',
47+
name: 'type',
48+
message: 'Select type',
49+
choices: types,
50+
},
51+
{
52+
type: 'list',
53+
name: 'scope',
54+
message: 'Denote the SCOPE of this change (optional):\n',
55+
choices: scopes,
56+
},
57+
{
58+
type: 'input',
59+
name: 'subject',
60+
message: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
61+
validate: subject =>
62+
subject.length === 0 ? 'subject is required' : true,
63+
},
64+
...migrationQuestions,
65+
{
66+
type: 'input',
67+
name: 'body',
68+
message:
69+
'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
70+
},
71+
{
72+
type: 'input',
73+
name: 'breaking',
74+
message: 'List any BREAKING CHANGES (optional):\n',
75+
},
76+
{
77+
type: 'input',
78+
name: 'issues',
79+
message:
80+
'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
81+
filter: (input, answers) => {
82+
return input.replace(/^\#/g, 'gh-');
83+
},
84+
},
85+
{
86+
type: 'expand',
87+
name: 'confirmCommit',
88+
choices: [
89+
{key: 'y', name: 'Yes', value: 'yes'},
90+
{key: 'n', name: 'Abort commit', value: 'no'},
91+
],
92+
default: 0,
93+
message(answers) {
94+
const SEP =
95+
'###--------------------------------------------------------###';
96+
console.log(`\n${SEP}\n${buildCommit({answers, gitInfo})}\n${SEP}\n`);
97+
return 'Are you sure you want to proceed with the commit above?';
98+
},
99+
},
100+
];
101+
},
102+
commitMessage({answers, gitInfo}) {
103+
if (answers.confirmCommit === 'yes') {
104+
return buildCommit({answers, gitInfo});
105+
} else {
106+
throw Error('Commit cancelled.');
107+
}
108+
},
109+
};
110+
111+
function buildCommit({answers, gitInfo}) {
112+
const migrationKeys = Object.keys(answers).filter(q =>
113+
q.includes('migration-'),
114+
);
115+
const migrationAnswers = migrationKeys
116+
.map(key => `${key}- ${answers[key]}`)
117+
.join('\n');
118+
const migrations =
119+
migrationAnswers && migrationAnswers.length > 0
120+
? `MIGRATION CHANGE:\n${migrationAnswers}`
121+
: false;
122+
const scope = answers.scope ? `(${answers.scope})` : false;
123+
const head = `${answers.type}${scope}: ${answers.subject}`;
124+
const body = answers.body ? answers.body : false;
125+
const breaking = answers.breaking
126+
? `BREAKING CHANGE:\n${answers.breaking}`
127+
: false;
128+
const issues = answers.issues
129+
? answers.issues.split(', ').join('\n').valueOf()
130+
: false;
131+
132+
return escapeSpecialChars(
133+
[head, body, migrations, breaking, issues].filter(p => p).join('\n\n'),
134+
);
135+
}
136+
137+
function getMigrationChanges(staged) {
138+
let migrationPaths = staged
139+
.map(
140+
filePath =>
141+
filePath.includes('migrations/') && filePath.split(/\//).pop(),
142+
)
143+
.filter(f => f && f.length > 0);
144+
let timestamps = {};
145+
for (let item of migrationPaths) {
146+
let match = item.match(/[0-9]{14}/g);
147+
if (match && match[0]) {
148+
timestamps[match[0]] = [...(timestamps[match[0]] || []), item];
149+
}
150+
}
151+
let questions = [];
152+
Object.keys(timestamps).forEach(timestamp => {
153+
questions.push({
154+
type: 'input',
155+
name: `migration-${timestamp}`,
156+
message: `Write a description of the changes in migrations for timestamp - ${timestamp}:\n`,
157+
validate: description =>
158+
description.length === 0 ? 'description is required' : true,
159+
});
160+
});
161+
return questions;
162+
}
163+
164+
const escapeSpecialChars = result => {
165+
// eslint-disable-next-line no-useless-escape
166+
const specialChars = ['`'];
167+
168+
let newResult = result;
169+
// eslint-disable-next-line array-callback-return
170+
specialChars.map(item => {
171+
// If user types "feat: `string`", the commit preview should show "feat: `\string\`".
172+
// Don't worry. The git log will be "feat: `string`"
173+
newResult = result.replace(new RegExp(item, 'g'), '\\`');
174+
});
175+
return newResult;
176+
};

.github/CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at support@sourcefuse.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

.github/CONTRIBUTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# loopback4-microservice-catalog
2+
3+
## Contributing
4+
5+
First off, thank you for considering contributing to the project. It's people like you that helps in keeping this extension useful.
6+
7+
### Where do I go from here ?
8+
9+
If you've noticed a bug or have a question, [search the issue tracker](https://github.com/sourcefuse/angular-boilerplate/issues) to see if
10+
someone else in the community has already created a ticket. If not, go ahead and
11+
[make one](https://github.com/sourcefuse/angular-boilerplate/issues/new/choose)!
12+
13+
### Fork & create a branch
14+
15+
If this is something you think you can fix, then [fork](https://help.github.com/articles/fork-a-repo) this repo and
16+
create a branch with a descriptive name.
17+
18+
A good branch name would be (where issue #325 is the ticket you're working on):
19+
20+
```sh
21+
git checkout -b 325-add-new-feature
22+
```
23+
24+
### Make a Pull Request
25+
26+
At this point, you should switch back to your master branch and make sure it's
27+
up to date with loopback4-microservice-catalog's master branch:
28+
29+
```sh
30+
git remote add upstream git@github.com:sourcefuse/angular-boilerplate.git
31+
git checkout master
32+
git pull upstream master
33+
```
34+
35+
Then update your feature branch from your local copy of master, and push it!
36+
37+
```sh
38+
git checkout 325-add-new-feature
39+
git rebase master
40+
git push --set-upstream origin 325-add-new-feature
41+
```
42+
43+
Finally, go to GitHub and [make a Pull Request](https://help.github.com/articles/creating-a-pull-request).
44+
45+
### Keeping your Pull Request updated
46+
47+
If a maintainer asks you to "rebase" your PR, they're saying that a lot of code
48+
has changed, and that you need to update your branch so it's easier to merge.
49+
50+
To learn more about rebasing in Git, there are a lot of [good][git rebasing]
51+
[resources][interactive rebase] but here's the suggested workflow:
52+
53+
```sh
54+
git checkout 325-add-new-feature
55+
git pull --rebase upstream master
56+
git push --force-with-lease 325-add-new-feature
57+
```
58+
59+
[git rebasing]: http://git-scm.com/book/en/Git-Branching-Rebasing
60+
[interactive rebase]: https://help.github.com/articles/interactive-rebase

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] Intermediate change (work in progress)
15+
16+
## How Has This Been Tested?
17+
18+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19+
20+
- [ ] Test A
21+
- [ ] Test B
22+
23+
## Checklist:
24+
25+
- [ ] Performed a self-review of my own code
26+
- [ ] npm test passes on your machine
27+
- [ ] New tests added or existing tests modified to cover all changes
28+
- [ ] Code conforms with the style guide
29+
- [ ] API Documentation in code was updated
30+
- [ ] Any dependent changes have been merged and published in downstream modules

.github/semantic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
titleAndCommits: true
2+
anyCommit: true

0 commit comments

Comments
 (0)