@7365admin1/module-hygiene 4.28.0 → 4.28.1-staging.7
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/.github/workflows/publish-staging.yml +36 -0
- package/dist/index.js +57 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish Staging
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- staging
|
|
6
|
+
|
|
7
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20.x
|
|
18
|
+
cache: "yarn"
|
|
19
|
+
cache-dependency-path: yarn.lock
|
|
20
|
+
|
|
21
|
+
- run: yarn install --immutable
|
|
22
|
+
|
|
23
|
+
- run: yarn build
|
|
24
|
+
|
|
25
|
+
- name: Create .npmrc for publishing
|
|
26
|
+
run: |
|
|
27
|
+
echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ~/.npmrc
|
|
28
|
+
|
|
29
|
+
- name: Set staging prerelease version
|
|
30
|
+
run: |
|
|
31
|
+
BASE=$(node -p "const [x,y,z]=require('./package.json').version.split('-')[0].split('.'); [x,y,+z+1].join('.')")
|
|
32
|
+
npm version "$BASE-staging.${{ github.run_number }}" --no-git-tag-version
|
|
33
|
+
node -p "'Publishing ' + require('./package.json').version"
|
|
34
|
+
|
|
35
|
+
- name: Publish to npm with staging tag
|
|
36
|
+
run: npm publish --tag staging --registry https://registry.npmjs.org
|
package/dist/index.js
CHANGED
|
@@ -1663,7 +1663,7 @@ function useUnitRepository() {
|
|
|
1663
1663
|
function useAreaService() {
|
|
1664
1664
|
const { createArea: _createArea, getAreasForChecklist } = useAreaRepo();
|
|
1665
1665
|
const { generateAreaExcel } = useAreaExportService();
|
|
1666
|
-
const { getUnits: _getUnits } = useUnitRepository();
|
|
1666
|
+
const { createUnit: _createUnit, getUnits: _getUnits } = useUnitRepository();
|
|
1667
1667
|
async function importArea({
|
|
1668
1668
|
dataJson,
|
|
1669
1669
|
site,
|
|
@@ -1745,23 +1745,40 @@ function useAreaService() {
|
|
|
1745
1745
|
areaData.set = setNumber;
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
|
-
if (row.UNITS
|
|
1748
|
+
if (row.UNITS) {
|
|
1749
1749
|
const unitNames = String(row.UNITS).split(",").map((u) => u.trim()).filter((u) => u);
|
|
1750
1750
|
if (unitNames.length > 0) {
|
|
1751
1751
|
const areaUnits = [];
|
|
1752
1752
|
for (const unitName of unitNames) {
|
|
1753
|
-
|
|
1753
|
+
let foundUnit = availableUnits.find(
|
|
1754
1754
|
(u) => u.name.toLowerCase() === unitName.toLowerCase()
|
|
1755
1755
|
);
|
|
1756
|
+
if (!foundUnit) {
|
|
1757
|
+
try {
|
|
1758
|
+
const insertedUnitId = await _createUnit({
|
|
1759
|
+
name: unitName,
|
|
1760
|
+
site,
|
|
1761
|
+
serviceType
|
|
1762
|
+
});
|
|
1763
|
+
foundUnit = {
|
|
1764
|
+
_id: insertedUnitId,
|
|
1765
|
+
name: unitName
|
|
1766
|
+
};
|
|
1767
|
+
availableUnits.push(foundUnit);
|
|
1768
|
+
import_node_server_utils8.logger.info(
|
|
1769
|
+
`Successfully created missing unit "${unitName}" for area "${areaName}"`
|
|
1770
|
+
);
|
|
1771
|
+
} catch (error) {
|
|
1772
|
+
import_node_server_utils8.logger.warn(
|
|
1773
|
+
`Unit "${unitName}" could not be created for area "${areaName}": ${error.message}`
|
|
1774
|
+
);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1756
1777
|
if (foundUnit) {
|
|
1757
1778
|
areaUnits.push({
|
|
1758
1779
|
unit: foundUnit._id,
|
|
1759
1780
|
name: foundUnit.name
|
|
1760
1781
|
});
|
|
1761
|
-
} else {
|
|
1762
|
-
import_node_server_utils8.logger.warn(
|
|
1763
|
-
`Unit "${unitName}" not found in site for area "${areaName}"`
|
|
1764
|
-
);
|
|
1765
1782
|
}
|
|
1766
1783
|
}
|
|
1767
1784
|
if (areaUnits.length > 0) {
|
|
@@ -2148,6 +2165,13 @@ function useUnitService() {
|
|
|
2148
2165
|
updateUnit: _updateUnit,
|
|
2149
2166
|
deleteUnit: _deleteUnit
|
|
2150
2167
|
} = useUnitRepository();
|
|
2168
|
+
function getUnitNamesFromRow(row) {
|
|
2169
|
+
const unitValue = row?.UNIT ?? row?.UNITS;
|
|
2170
|
+
if (!unitValue) {
|
|
2171
|
+
return [];
|
|
2172
|
+
}
|
|
2173
|
+
return String(unitValue).split(",").map((unit) => unit.trim()).filter((unit) => unit && !unit.startsWith("Sample:"));
|
|
2174
|
+
}
|
|
2151
2175
|
async function importUnit({
|
|
2152
2176
|
dataJson,
|
|
2153
2177
|
site,
|
|
@@ -2173,36 +2197,35 @@ function useUnitService() {
|
|
|
2173
2197
|
try {
|
|
2174
2198
|
for (let i = 0; i < dataArray.length; i++) {
|
|
2175
2199
|
const row = dataArray[i];
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
continue;
|
|
2180
|
-
}
|
|
2181
|
-
const unitName = String(row.UNIT).trim();
|
|
2182
|
-
if (!unitName) {
|
|
2183
|
-
import_node_server_utils11.logger.warn(`Skipping row ${i + 1} with empty unit name`);
|
|
2184
|
-
skippedRows.push(i + 1);
|
|
2185
|
-
continue;
|
|
2186
|
-
}
|
|
2187
|
-
if (unitName.startsWith("Sample:")) {
|
|
2188
|
-
import_node_server_utils11.logger.warn(`Skipping row ${i + 1} with sample unit: ${unitName}`);
|
|
2200
|
+
const unitNames = getUnitNamesFromRow(row);
|
|
2201
|
+
if (unitNames.length === 0) {
|
|
2202
|
+
import_node_server_utils11.logger.warn(`Skipping row ${i + 1} with missing UNIT/UNITS:`, row);
|
|
2189
2203
|
skippedRows.push(i + 1);
|
|
2190
2204
|
continue;
|
|
2191
2205
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
+
const uniqueUnitNames = Array.from(
|
|
2207
|
+
new Set(unitNames.map((unitName) => unitName.toLowerCase()))
|
|
2208
|
+
).map(
|
|
2209
|
+
(lowerUnitName) => unitNames.find(
|
|
2210
|
+
(unitName) => unitName.toLowerCase() === lowerUnitName
|
|
2211
|
+
)
|
|
2212
|
+
);
|
|
2213
|
+
for (const unitName of uniqueUnitNames) {
|
|
2214
|
+
try {
|
|
2215
|
+
const insertedId = await _createUnit({
|
|
2216
|
+
name: unitName,
|
|
2217
|
+
site,
|
|
2218
|
+
serviceType
|
|
2219
|
+
});
|
|
2220
|
+
insertedUnitIds.push(insertedId);
|
|
2221
|
+
import_node_server_utils11.logger.info(`Successfully created unit: ${unitName}`);
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
import_node_server_utils11.logger.error(`Error creating unit "${unitName}": ${error.message}`);
|
|
2224
|
+
if (error.message.includes("Unit already exists")) {
|
|
2225
|
+
duplicateUnits.push(unitName);
|
|
2226
|
+
} else {
|
|
2227
|
+
failedUnits.push(unitName);
|
|
2228
|
+
}
|
|
2206
2229
|
}
|
|
2207
2230
|
}
|
|
2208
2231
|
}
|