Skip to content

Commit 002fe49

Browse files
authored
Merge pull request #15 from Gallimore-Software/feature/NFG-83-Setup-Infrastructure
Feature/nfg 83 setup infrastructure
2 parents 2fbff66 + 6d438fd commit 002fe49

File tree

5 files changed

+146
-146
lines changed

5 files changed

+146
-146
lines changed

.husky/pre-commit

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#!/bin/sh
2-
# This hook checks that branches are named according to the convention.
3-
1+
# This hook checks that branches are named according to the updated convention.
42
current_branch=$(git rev-parse --abbrev-ref HEAD)
5-
branch_regex="^(feature|bugfix|hotfix|release)/NFG-[0-9]+-.+$"
3+
branch_regex="^(development|staging|testing|production|(^(feature|bugfix|hotfix|release)/NFG-[0-9]+-.+$)$)"
64

7-
if ! echo "$current_branch" | grep -Eq "$branch_regex"; then
8-
echo "Error: Branch name '$current_branch' does not follow the naming convention."
9-
echo "Please rename your branch to follow the convention: (feature|bugfix|hotfix|release)/NFG-123-description."
10-
exit 1
5+
if ! echo "$current_branch" | grep -qE "$branch_regex"; then
6+
echo "Error: Branch name '$current_branch' does not follow the naming convention."
7+
echo "Please rename your branch to follow the convention: "
8+
echo " - For environment branches: (development|staging|testing|production)"
9+
echo " - For feature branches: (feature|bugfix|hotfix|release)/NFG-<issue-number>-description."
10+
exit 1
1111
fi
1212

13-
# Lint staged files
13+
# Format staged files using Prettier
1414
prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
1515
git update-index --again

.husky/pre-push

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ protected_branches='development|testing|staging|production'
55

66
current_branch=$(git rev-parse --abbrev-ref HEAD)
77

8+
# Prevent direct push to protected branches
89
if echo "$current_branch" | grep -Eq "$protected_branches"; then
910
echo "Error: Direct push to $current_branch is not allowed."
1011
echo "Please use pull requests for changes to this branch."
1112
exit 1
1213
fi
1314

14-
# Do not allow push if missing Jira issue ID in commit message.
15+
# Allow commit messages that are merge commits to bypass Jira issue ID check
1516
while read local_ref local_sha remote_ref remote_sha; do
1617
if [ "$local_sha" = "0000000000000000000000000000000000000000" ]; then
1718
# Branch is being deleted, ignore
@@ -21,6 +22,13 @@ while read local_ref local_sha remote_ref remote_sha; do
2122
COMMITS=$(git rev-list $remote_sha..$local_sha)
2223
for COMMIT in $COMMITS; do
2324
MESSAGE=$(git log --format=%B -n 1 $COMMIT)
25+
26+
# Skip the check for merge commits
27+
if [[ $MESSAGE =~ ^Merge ]]; then
28+
continue
29+
fi
30+
31+
# Enforce Jira issue ID in other commit messages
2432
if [[ ! $MESSAGE =~ NFG-[0-9]+ ]]; then
2533
echo "Error: Commit message '$MESSAGE' does not contain a Jira issue ID (NFG-<issue-number>)."
2634
exit 1

clients/nufacturing

Submodule nufacturing updated 19 files

nufacturing-local-db.inventories.json

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,110 @@
1-
[{
2-
"_id": {
3-
"$oid": "66b10a070832a64c4be3fc3b"
4-
},
5-
"type": "Nufacturing",
6-
"category": "Raw Materials",
7-
"subCategory": "Customer 1",
8-
"items": [
9-
{
10-
"ingredientName": "Ingredient A",
11-
"pricePerKg": 25.5,
12-
"stockQuantity": 100,
13-
"_id": {
14-
"$oid": "66b10a070832a64c4be3fc3c"
15-
}
1+
[
2+
{
3+
"_id": {
4+
"$oid": "66b10a070832a64c4be3fc3b"
165
},
17-
{
18-
"ingredientName": "Ingredient B",
19-
"pricePerKg": 30.75,
20-
"stockQuantity": 200,
21-
"_id": {
22-
"$oid": "66b10a070832a64c4be3fc3d"
6+
"type": "Nufacturing",
7+
"category": "Raw Materials",
8+
"subCategory": "Customer 1",
9+
"items": [
10+
{
11+
"ingredientName": "Ingredient A",
12+
"pricePerKg": 25.5,
13+
"stockQuantity": 100,
14+
"_id": {
15+
"$oid": "66b10a070832a64c4be3fc3c"
16+
}
17+
},
18+
{
19+
"ingredientName": "Ingredient B",
20+
"pricePerKg": 30.75,
21+
"stockQuantity": 200,
22+
"_id": {
23+
"$oid": "66b10a070832a64c4be3fc3d"
24+
}
2325
}
24-
}
25-
],
26-
"createdBy": {
27-
"$oid": "66acbdd0f935ee75c29eb4cd"
28-
},
29-
"createdAt": {
30-
"$date": "2024-08-05T17:21:11.236Z"
31-
},
32-
"updatedAt": {
33-
"$date": "2024-08-05T17:21:11.236Z"
34-
},
35-
"__v": 0
36-
},
37-
{
38-
"_id": {
39-
"$oid": "66b10a4f0832a64c4be3fc40"
26+
],
27+
"createdBy": {
28+
"$oid": "66acbdd0f935ee75c29eb4cd"
29+
},
30+
"createdAt": {
31+
"$date": "2024-08-05T17:21:11.236Z"
32+
},
33+
"updatedAt": {
34+
"$date": "2024-08-05T17:21:11.236Z"
35+
},
36+
"__v": 0
4037
},
41-
"type": "Customer Supplied",
42-
"category": "Packaging",
43-
"subCategory": "Supplier X",
44-
"items": [
45-
{
46-
"ingredientName": "Packaging Material A",
47-
"pricePerKg": 12,
48-
"stockQuantity": 500,
49-
"_id": {
50-
"$oid": "66b10a4f0832a64c4be3fc41"
51-
}
38+
{
39+
"_id": {
40+
"$oid": "66b10a4f0832a64c4be3fc40"
5241
},
53-
{
54-
"ingredientName": "Packaging Material B",
55-
"pricePerKg": 8.5,
56-
"stockQuantity": 750,
57-
"_id": {
58-
"$oid": "66b10a4f0832a64c4be3fc42"
42+
"type": "Customer Supplied",
43+
"category": "Packaging",
44+
"subCategory": "Supplier X",
45+
"items": [
46+
{
47+
"ingredientName": "Packaging Material A",
48+
"pricePerKg": 12,
49+
"stockQuantity": 500,
50+
"_id": {
51+
"$oid": "66b10a4f0832a64c4be3fc41"
52+
}
53+
},
54+
{
55+
"ingredientName": "Packaging Material B",
56+
"pricePerKg": 8.5,
57+
"stockQuantity": 750,
58+
"_id": {
59+
"$oid": "66b10a4f0832a64c4be3fc42"
60+
}
5961
}
60-
}
61-
],
62-
"createdBy": {
63-
"$oid": "66acbdd0f935ee75c29eb4cd"
64-
},
65-
"createdAt": {
66-
"$date": "2024-08-05T17:22:23.837Z"
67-
},
68-
"updatedAt": {
69-
"$date": "2024-08-05T17:22:23.837Z"
70-
},
71-
"__v": 0
72-
},
73-
{
74-
"_id": {
75-
"$oid": "66b10d8f0832a64c4be3fc8a"
62+
],
63+
"createdBy": {
64+
"$oid": "66acbdd0f935ee75c29eb4cd"
65+
},
66+
"createdAt": {
67+
"$date": "2024-08-05T17:22:23.837Z"
68+
},
69+
"updatedAt": {
70+
"$date": "2024-08-05T17:22:23.837Z"
71+
},
72+
"__v": 0
7673
},
77-
"type": "R&D/Lab",
78-
"category": "Labels",
79-
"subCategory": "Test Batch",
80-
"items": [
81-
{
82-
"ingredientName": "Label A",
83-
"pricePerKg": 5.25,
84-
"stockQuantity": 300,
85-
"_id": {
86-
"$oid": "66b10d8f0832a64c4be3fc8b"
87-
}
74+
{
75+
"_id": {
76+
"$oid": "66b10d8f0832a64c4be3fc8a"
8877
},
89-
{
90-
"ingredientName": "Label B",
91-
"pricePerKg": 6.75,
92-
"stockQuantity": 150,
93-
"_id": {
94-
"$oid": "66b10d8f0832a64c4be3fc8c"
78+
"type": "R&D/Lab",
79+
"category": "Labels",
80+
"subCategory": "Test Batch",
81+
"items": [
82+
{
83+
"ingredientName": "Label A",
84+
"pricePerKg": 5.25,
85+
"stockQuantity": 300,
86+
"_id": {
87+
"$oid": "66b10d8f0832a64c4be3fc8b"
88+
}
89+
},
90+
{
91+
"ingredientName": "Label B",
92+
"pricePerKg": 6.75,
93+
"stockQuantity": 150,
94+
"_id": {
95+
"$oid": "66b10d8f0832a64c4be3fc8c"
96+
}
9597
}
96-
}
97-
],
98-
"createdBy": {
99-
"$oid": "66acbdd0f935ee75c29eb4cd"
100-
},
101-
"createdAt": {
102-
"$date": "2024-08-05T17:36:15.331Z"
103-
},
104-
"updatedAt": {
105-
"$date": "2024-08-05T17:36:15.331Z"
106-
},
107-
"__v": 0
108-
}]
98+
],
99+
"createdBy": {
100+
"$oid": "66acbdd0f935ee75c29eb4cd"
101+
},
102+
"createdAt": {
103+
"$date": "2024-08-05T17:36:15.331Z"
104+
},
105+
"updatedAt": {
106+
"$date": "2024-08-05T17:36:15.331Z"
107+
},
108+
"__v": 0
109+
}
110+
]

src/controllers/inventoryController.js

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ exports.getAllInventoryItems = async (req, res) => {
1616
res.status(200).json({ success: true, data: inventoryItems });
1717
} catch (err) {
1818
console.error(err);
19-
res
20-
.status(500)
21-
.json({
22-
success: false,
23-
message: "Error fetching inventory items",
24-
error: err.message,
25-
});
19+
res.status(500).json({
20+
success: false,
21+
message: "Error fetching inventory items",
22+
error: err.message,
23+
});
2624
}
2725
};
2826

@@ -46,13 +44,11 @@ exports.getInventoryItemById = async (req, res) => {
4644
res.status(200).json({ success: true, data: inventoryItem });
4745
} catch (err) {
4846
console.error(err);
49-
res
50-
.status(500)
51-
.json({
52-
success: false,
53-
message: "Error fetching inventory item",
54-
error: err.message,
55-
});
47+
res.status(500).json({
48+
success: false,
49+
message: "Error fetching inventory item",
50+
error: err.message,
51+
});
5652
}
5753
};
5854

@@ -64,13 +60,11 @@ exports.createInventoryItem = async (req, res) => {
6460
res.status(201).json({ success: true, data: newInventoryItem });
6561
} catch (err) {
6662
console.error(err);
67-
res
68-
.status(500)
69-
.json({
70-
success: false,
71-
message: "Error creating inventory item",
72-
error: err.message,
73-
});
63+
res.status(500).json({
64+
success: false,
65+
message: "Error creating inventory item",
66+
error: err.message,
67+
});
7468
}
7569
};
7670

@@ -99,13 +93,11 @@ exports.updateInventoryItem = async (req, res) => {
9993
res.status(200).json({ success: true, data: updatedInventoryItem });
10094
} catch (err) {
10195
console.error(err);
102-
res
103-
.status(500)
104-
.json({
105-
success: false,
106-
message: "Error updating inventory item",
107-
error: err.message,
108-
});
96+
res.status(500).json({
97+
success: false,
98+
message: "Error updating inventory item",
99+
error: err.message,
100+
});
109101
}
110102
};
111103

@@ -125,12 +117,10 @@ exports.deleteInventoryItem = async (req, res) => {
125117
.json({ success: true, message: "Inventory item deleted successfully" });
126118
} catch (err) {
127119
console.error(err);
128-
res
129-
.status(500)
130-
.json({
131-
success: false,
132-
message: "Error deleting inventory item",
133-
error: err.message,
134-
});
120+
res.status(500).json({
121+
success: false,
122+
message: "Error deleting inventory item",
123+
error: err.message,
124+
});
135125
}
136126
};

0 commit comments

Comments
 (0)