@knocklabs/cli 1.0.2 → 1.0.3
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/README.md +104 -80
- package/dist/commands/audience/push.js +6 -1
- package/dist/commands/guide/push.js +2 -1
- package/dist/commands/layout/push.js +2 -1
- package/dist/commands/message-type/push.js +2 -1
- package/dist/commands/partial/push.js +2 -1
- package/dist/commands/push.js +5 -1
- package/dist/commands/translation/push.js +2 -1
- package/dist/commands/workflow/push.js +2 -1
- package/dist/lib/api-v1.js +12 -6
- package/dist/lib/helpers/flag.js +6 -0
- package/dist/lib/marshal/translation/helpers.js +2 -1
- package/dist/lib/marshal/translation/reader.js +1 -1
- package/dist/lib/run-context/loader.js +0 -3
- package/oclif.manifest.json +222 -174
- package/package.json +3 -3
|
@@ -112,6 +112,10 @@ class AudiencePush extends _basecommand.default {
|
|
|
112
112
|
commit: flags.commit,
|
|
113
113
|
commit_message: flags["commit-message"],
|
|
114
114
|
audience: audience.content
|
|
115
|
+
}, {
|
|
116
|
+
query: flags.force ? {
|
|
117
|
+
force: true
|
|
118
|
+
} : undefined
|
|
115
119
|
});
|
|
116
120
|
// Update the audience directory with the successfully pushed audience
|
|
117
121
|
// payload from the server.
|
|
@@ -158,7 +162,8 @@ _define_property(AudiencePush, "flags", {
|
|
|
158
162
|
dependsOn: [
|
|
159
163
|
"commit"
|
|
160
164
|
]
|
|
161
|
-
})
|
|
165
|
+
}),
|
|
166
|
+
force: _flag.force
|
|
162
167
|
});
|
|
163
168
|
_define_property(AudiencePush, "args", {
|
|
164
169
|
audienceKey: _core.Args.string({
|
package/dist/commands/push.js
CHANGED
|
@@ -112,6 +112,9 @@ class Push extends _basecommand.default {
|
|
|
112
112
|
...flags["commit-message"] ? [
|
|
113
113
|
"--commit-message",
|
|
114
114
|
flags["commit-message"]
|
|
115
|
+
] : [],
|
|
116
|
+
...flags.force ? [
|
|
117
|
+
"--force"
|
|
115
118
|
] : []
|
|
116
119
|
];
|
|
117
120
|
// Note: Because we're pushing the different resource types sequentially,
|
|
@@ -147,7 +150,8 @@ _define_property(Push, "flags", {
|
|
|
147
150
|
dependsOn: [
|
|
148
151
|
"commit"
|
|
149
152
|
]
|
|
150
|
-
})
|
|
153
|
+
}),
|
|
154
|
+
force: _flag.force
|
|
151
155
|
});
|
|
152
156
|
const runResourcePushCommand = async (resourceType, targetDirCtx, args)=>{
|
|
153
157
|
const subdirPath = _nodepath.resolve(targetDirCtx.abspath, _resources.RESOURCE_SUBDIRS[resourceType]);
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -73,7 +73,8 @@ class ApiV1 {
|
|
|
73
73
|
branch: flags.branch,
|
|
74
74
|
annotate: flags.annotate,
|
|
75
75
|
commit: flags.commit,
|
|
76
|
-
commit_message: flags["commit-message"]
|
|
76
|
+
commit_message: flags["commit-message"],
|
|
77
|
+
force: flags.force
|
|
77
78
|
});
|
|
78
79
|
const data = {
|
|
79
80
|
workflow
|
|
@@ -187,7 +188,8 @@ class ApiV1 {
|
|
|
187
188
|
branch: flags.branch,
|
|
188
189
|
commit: flags.commit,
|
|
189
190
|
commit_message: flags["commit-message"],
|
|
190
|
-
namespace: translation.namespace
|
|
191
|
+
namespace: translation.namespace,
|
|
192
|
+
force: flags.force
|
|
191
193
|
});
|
|
192
194
|
return this.put(`/translations/${translation.locale_code}`, {
|
|
193
195
|
translation
|
|
@@ -238,7 +240,8 @@ class ApiV1 {
|
|
|
238
240
|
branch: flags.branch,
|
|
239
241
|
annotate: flags.annotate,
|
|
240
242
|
commit: flags.commit,
|
|
241
|
-
commit_message: flags["commit-message"]
|
|
243
|
+
commit_message: flags["commit-message"],
|
|
244
|
+
force: flags.force
|
|
242
245
|
});
|
|
243
246
|
const data = {
|
|
244
247
|
email_layout: layout
|
|
@@ -289,7 +292,8 @@ class ApiV1 {
|
|
|
289
292
|
branch: flags.branch,
|
|
290
293
|
annotate: flags.annotate,
|
|
291
294
|
commit: flags.commit,
|
|
292
|
-
commit_message: flags["commit-message"]
|
|
295
|
+
commit_message: flags["commit-message"],
|
|
296
|
+
force: flags.force
|
|
293
297
|
});
|
|
294
298
|
const data = {
|
|
295
299
|
partial
|
|
@@ -347,7 +351,8 @@ class ApiV1 {
|
|
|
347
351
|
branch: flags.branch,
|
|
348
352
|
annotate: flags.annotate,
|
|
349
353
|
commit: flags.commit,
|
|
350
|
-
commit_message: flags["commit-message"]
|
|
354
|
+
commit_message: flags["commit-message"],
|
|
355
|
+
force: flags.force
|
|
351
356
|
});
|
|
352
357
|
const data = {
|
|
353
358
|
message_type: messageType
|
|
@@ -411,7 +416,8 @@ class ApiV1 {
|
|
|
411
416
|
branch: flags.branch,
|
|
412
417
|
annotate: flags.annotate,
|
|
413
418
|
commit: flags.commit,
|
|
414
|
-
commit_message: flags["commit-message"]
|
|
419
|
+
commit_message: flags["commit-message"],
|
|
420
|
+
force: flags.force
|
|
415
421
|
});
|
|
416
422
|
const data = {
|
|
417
423
|
guide
|
package/dist/lib/helpers/flag.js
CHANGED
|
@@ -21,6 +21,9 @@ _export(exports, {
|
|
|
21
21
|
get filePath () {
|
|
22
22
|
return filePath;
|
|
23
23
|
},
|
|
24
|
+
get force () {
|
|
25
|
+
return force;
|
|
26
|
+
},
|
|
24
27
|
get jsonStr () {
|
|
25
28
|
return jsonStr;
|
|
26
29
|
},
|
|
@@ -152,3 +155,6 @@ const branch = slug({
|
|
|
152
155
|
// Using lodash's once avoids unnecessarily reading the branch file multiple times.
|
|
153
156
|
default: (0, _lodash.once)(_branch.readSlugFromBranchFile)
|
|
154
157
|
});
|
|
158
|
+
const force = _core.Flags.boolean({
|
|
159
|
+
summary: "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. " + "If you're using this on a non-development environment, you should also ensure you `commit` the changes."
|
|
160
|
+
});
|
|
@@ -103,7 +103,8 @@ const formatLanguage = (translation)=>{
|
|
|
103
103
|
const isValidLocale = (localeCode)=>Boolean(_localecodes.default.getByTag(localeCode));
|
|
104
104
|
const isTranslationDir = (dirPath)=>{
|
|
105
105
|
const locale = _nodepath.basename(dirPath);
|
|
106
|
-
|
|
106
|
+
const parentDirName = _nodepath.basename(_nodepath.dirname(dirPath));
|
|
107
|
+
return parentDirName === "translations" && isValidLocale(locale);
|
|
107
108
|
};
|
|
108
109
|
const buildTranslationFileCtx = async (dirPath, translationIdentifier, options)=>{
|
|
109
110
|
const ref = (0, _processorisomorphic.formatRef)(translationIdentifier.localeCode, translationIdentifier.namespace);
|
|
@@ -170,7 +170,7 @@ const readAllForCommandTarget = async (target)=>{
|
|
|
170
170
|
const dirents = await _fsextra.readdir(targetCtx.abspath, {
|
|
171
171
|
withFileTypes: true
|
|
172
172
|
});
|
|
173
|
-
const translationDirPaths = dirents.filter((dirent)=>dirent.isDirectory() && (0, _helpers.
|
|
173
|
+
const translationDirPaths = dirents.filter((dirent)=>dirent.isDirectory() && (0, _helpers.isValidLocale)(dirent.name)).map((dirent)=>_nodepath.resolve(targetCtx.abspath, dirent.name));
|
|
174
174
|
const translationFilePaths = (await Promise.all(translationDirPaths.map(async (abspath)=>(0, _helpers.lsTranslationDir)(abspath)))).flat();
|
|
175
175
|
return readTranslationFiles(translationFilePaths);
|
|
176
176
|
}
|
|
@@ -85,9 +85,6 @@ const evaluateRecursively = async (ctx, currDir)=>{
|
|
|
85
85
|
} else if (await _messagetype.isMessageTypeDir(currDir)) {
|
|
86
86
|
ctx.resourceDir = buildResourceDirContext("message_type", currDir);
|
|
87
87
|
} else if (_translation.isTranslationDir(currDir)) {
|
|
88
|
-
// NOTE: Must keep this check as last in the order of directory-type checks
|
|
89
|
-
// since the `isTranslationDir` only checks that the directory name is a
|
|
90
|
-
// valid locale name.
|
|
91
88
|
ctx.resourceDir = buildResourceDirContext("translation", currDir);
|
|
92
89
|
}
|
|
93
90
|
}
|