@lang-tag/cli 0.12.0 → 0.12.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.
- package/algorithms/index.cjs +12 -3
- package/algorithms/index.js +12 -3
- package/index.cjs +17 -14
- package/index.js +17 -14
- package/package.json +2 -2
package/algorithms/index.cjs
CHANGED
|
@@ -84,13 +84,22 @@ function pathBasedConfigGenerator(options = {}) {
|
|
|
84
84
|
const transformedParts = pathParts.map((part) => applyCaseTransform(part, pathCase));
|
|
85
85
|
path$1 = transformedParts.join(".");
|
|
86
86
|
}
|
|
87
|
-
const newConfig = {};
|
|
87
|
+
const newConfig = event.config ? { ...event.config } : {};
|
|
88
88
|
if (clearOnDefaultNamespace && namespace === actualFallbackNamespace) {
|
|
89
89
|
if (path$1) {
|
|
90
90
|
newConfig.path = path$1;
|
|
91
|
+
delete newConfig.namespace;
|
|
91
92
|
} else {
|
|
92
|
-
event.
|
|
93
|
-
|
|
93
|
+
const hasOtherProperties = event.config && Object.keys(event.config).some(
|
|
94
|
+
(key) => key !== "namespace" && key !== "path"
|
|
95
|
+
);
|
|
96
|
+
if (!hasOtherProperties) {
|
|
97
|
+
event.save(null, TRIGGER_NAME$1);
|
|
98
|
+
return;
|
|
99
|
+
} else {
|
|
100
|
+
delete newConfig.namespace;
|
|
101
|
+
delete newConfig.path;
|
|
102
|
+
}
|
|
94
103
|
}
|
|
95
104
|
} else {
|
|
96
105
|
if (namespace) {
|
package/algorithms/index.js
CHANGED
|
@@ -65,13 +65,22 @@ function pathBasedConfigGenerator(options = {}) {
|
|
|
65
65
|
const transformedParts = pathParts.map((part) => applyCaseTransform(part, pathCase));
|
|
66
66
|
path = transformedParts.join(".");
|
|
67
67
|
}
|
|
68
|
-
const newConfig = {};
|
|
68
|
+
const newConfig = event.config ? { ...event.config } : {};
|
|
69
69
|
if (clearOnDefaultNamespace && namespace === actualFallbackNamespace) {
|
|
70
70
|
if (path) {
|
|
71
71
|
newConfig.path = path;
|
|
72
|
+
delete newConfig.namespace;
|
|
72
73
|
} else {
|
|
73
|
-
event.
|
|
74
|
-
|
|
74
|
+
const hasOtherProperties = event.config && Object.keys(event.config).some(
|
|
75
|
+
(key) => key !== "namespace" && key !== "path"
|
|
76
|
+
);
|
|
77
|
+
if (!hasOtherProperties) {
|
|
78
|
+
event.save(null, TRIGGER_NAME$1);
|
|
79
|
+
return;
|
|
80
|
+
} else {
|
|
81
|
+
delete newConfig.namespace;
|
|
82
|
+
delete newConfig.path;
|
|
83
|
+
}
|
|
75
84
|
}
|
|
76
85
|
} else {
|
|
77
86
|
if (namespace) {
|
package/index.cjs
CHANGED
|
@@ -173,7 +173,7 @@ class $LT_TagProcessor {
|
|
|
173
173
|
}
|
|
174
174
|
const tag = R.tag;
|
|
175
175
|
let newTranslationsString = R.translations;
|
|
176
|
-
if (!newTranslationsString) newTranslationsString = this.config.translationArgPosition === 1 ? tag.parameter1Text : tag.parameter2Text;
|
|
176
|
+
if (!newTranslationsString) newTranslationsString = this.config.translationArgPosition === 1 ? tag.parameter1Text : tag.parameter2Text || "{}";
|
|
177
177
|
else if (typeof newTranslationsString !== "string") newTranslationsString = JSON5.stringify(newTranslationsString);
|
|
178
178
|
if (!newTranslationsString) throw new Error("Tag must have translations provided!");
|
|
179
179
|
try {
|
|
@@ -191,6 +191,9 @@ class $LT_TagProcessor {
|
|
|
191
191
|
throw new Error(`Tag config is invalid object! Config: ${newConfigString}`);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
if (newConfigString === null && this.config.translationArgPosition === 2) {
|
|
195
|
+
newConfigString = "{}";
|
|
196
|
+
}
|
|
194
197
|
const arg1 = this.config.translationArgPosition === 1 ? newTranslationsString : newConfigString;
|
|
195
198
|
const arg2 = this.config.translationArgPosition === 1 ? newConfigString : newTranslationsString;
|
|
196
199
|
let tagFunction = `${this.config.tagName}(${arg1}`;
|
|
@@ -512,7 +515,7 @@ const LANG_TAG_DEFAULT_CONFIG = {
|
|
|
512
515
|
await event.logger.conflict(event.conflict, true);
|
|
513
516
|
},
|
|
514
517
|
onCollectFinish: (event) => {
|
|
515
|
-
event.exit();
|
|
518
|
+
if (event.conflicts.length) event.exit();
|
|
516
519
|
}
|
|
517
520
|
},
|
|
518
521
|
import: {
|
|
@@ -1215,18 +1218,18 @@ async function $LT_GroupTagsToNamespaces({ logger, files, config }) {
|
|
|
1215
1218
|
}
|
|
1216
1219
|
if (allConflicts.length > 0) {
|
|
1217
1220
|
logger.warn(`Found ${allConflicts.length} conflicts.`);
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
});
|
|
1227
|
-
if (!shouldContinue) {
|
|
1228
|
-
throw new Error(`LangTagConflictResolution:Processing stopped due to collect finish handler`);
|
|
1221
|
+
}
|
|
1222
|
+
if (config.collect?.onCollectFinish) {
|
|
1223
|
+
let shouldContinue = true;
|
|
1224
|
+
config.collect.onCollectFinish({
|
|
1225
|
+
conflicts: allConflicts,
|
|
1226
|
+
logger,
|
|
1227
|
+
exit() {
|
|
1228
|
+
shouldContinue = false;
|
|
1229
1229
|
}
|
|
1230
|
+
});
|
|
1231
|
+
if (!shouldContinue) {
|
|
1232
|
+
throw new Error(`LangTagConflictResolution:Processing stopped due to collect finish handler`);
|
|
1230
1233
|
}
|
|
1231
1234
|
}
|
|
1232
1235
|
return namespaces;
|
|
@@ -1478,7 +1481,7 @@ const config = {
|
|
|
1478
1481
|
// Call event.exit(); to terminate the process upon the first conflict
|
|
1479
1482
|
},
|
|
1480
1483
|
onCollectFinish: event => {
|
|
1481
|
-
event.exit(); // Stop the process to avoid merging on conflict
|
|
1484
|
+
if (event.conflicts.length) event.exit(); // Stop the process to avoid merging on conflict
|
|
1482
1485
|
}
|
|
1483
1486
|
},
|
|
1484
1487
|
translationArgPosition: 1,
|
package/index.js
CHANGED
|
@@ -153,7 +153,7 @@ class $LT_TagProcessor {
|
|
|
153
153
|
}
|
|
154
154
|
const tag = R.tag;
|
|
155
155
|
let newTranslationsString = R.translations;
|
|
156
|
-
if (!newTranslationsString) newTranslationsString = this.config.translationArgPosition === 1 ? tag.parameter1Text : tag.parameter2Text;
|
|
156
|
+
if (!newTranslationsString) newTranslationsString = this.config.translationArgPosition === 1 ? tag.parameter1Text : tag.parameter2Text || "{}";
|
|
157
157
|
else if (typeof newTranslationsString !== "string") newTranslationsString = JSON5.stringify(newTranslationsString);
|
|
158
158
|
if (!newTranslationsString) throw new Error("Tag must have translations provided!");
|
|
159
159
|
try {
|
|
@@ -171,6 +171,9 @@ class $LT_TagProcessor {
|
|
|
171
171
|
throw new Error(`Tag config is invalid object! Config: ${newConfigString}`);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
if (newConfigString === null && this.config.translationArgPosition === 2) {
|
|
175
|
+
newConfigString = "{}";
|
|
176
|
+
}
|
|
174
177
|
const arg1 = this.config.translationArgPosition === 1 ? newTranslationsString : newConfigString;
|
|
175
178
|
const arg2 = this.config.translationArgPosition === 1 ? newConfigString : newTranslationsString;
|
|
176
179
|
let tagFunction = `${this.config.tagName}(${arg1}`;
|
|
@@ -492,7 +495,7 @@ const LANG_TAG_DEFAULT_CONFIG = {
|
|
|
492
495
|
await event.logger.conflict(event.conflict, true);
|
|
493
496
|
},
|
|
494
497
|
onCollectFinish: (event) => {
|
|
495
|
-
event.exit();
|
|
498
|
+
if (event.conflicts.length) event.exit();
|
|
496
499
|
}
|
|
497
500
|
},
|
|
498
501
|
import: {
|
|
@@ -1195,18 +1198,18 @@ async function $LT_GroupTagsToNamespaces({ logger, files, config }) {
|
|
|
1195
1198
|
}
|
|
1196
1199
|
if (allConflicts.length > 0) {
|
|
1197
1200
|
logger.warn(`Found ${allConflicts.length} conflicts.`);
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
});
|
|
1207
|
-
if (!shouldContinue) {
|
|
1208
|
-
throw new Error(`LangTagConflictResolution:Processing stopped due to collect finish handler`);
|
|
1201
|
+
}
|
|
1202
|
+
if (config.collect?.onCollectFinish) {
|
|
1203
|
+
let shouldContinue = true;
|
|
1204
|
+
config.collect.onCollectFinish({
|
|
1205
|
+
conflicts: allConflicts,
|
|
1206
|
+
logger,
|
|
1207
|
+
exit() {
|
|
1208
|
+
shouldContinue = false;
|
|
1209
1209
|
}
|
|
1210
|
+
});
|
|
1211
|
+
if (!shouldContinue) {
|
|
1212
|
+
throw new Error(`LangTagConflictResolution:Processing stopped due to collect finish handler`);
|
|
1210
1213
|
}
|
|
1211
1214
|
}
|
|
1212
1215
|
return namespaces;
|
|
@@ -1458,7 +1461,7 @@ const config = {
|
|
|
1458
1461
|
// Call event.exit(); to terminate the process upon the first conflict
|
|
1459
1462
|
},
|
|
1460
1463
|
onCollectFinish: event => {
|
|
1461
|
-
event.exit(); // Stop the process to avoid merging on conflict
|
|
1464
|
+
if (event.conflicts.length) event.exit(); // Stop the process to avoid merging on conflict
|
|
1462
1465
|
}
|
|
1463
1466
|
},
|
|
1464
1467
|
translationArgPosition: 1,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lang-tag/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/TheTonsOfCode/lang-tag"
|
|
10
|
+
"url": "https://github.com/TheTonsOfCode/lang-tag-cli"
|
|
11
11
|
},
|
|
12
12
|
"author": "TheTonsOfCode",
|
|
13
13
|
"license": "MIT",
|