@knocklabs/cli 0.2.1 → 0.2.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 +258 -36
- package/dist/commands/branch/create.js +1 -1
- package/dist/commands/branch/delete.js +1 -1
- package/dist/commands/branch/exit.js +44 -0
- package/dist/commands/branch/switch.js +161 -0
- package/dist/commands/commit/get.js +4 -4
- package/dist/commands/commit/index.js +47 -2
- package/dist/commands/commit/list.js +61 -13
- package/dist/commands/guide/activate.js +48 -4
- package/dist/commands/guide/generate-types.js +4 -1
- package/dist/commands/guide/get.js +46 -3
- package/dist/commands/guide/list.js +46 -3
- package/dist/commands/guide/pull.js +6 -4
- package/dist/commands/guide/push.js +4 -3
- package/dist/commands/guide/validate.js +4 -3
- package/dist/commands/layout/get.js +46 -1
- package/dist/commands/layout/list.js +46 -1
- package/dist/commands/layout/pull.js +6 -2
- package/dist/commands/layout/push.js +4 -1
- package/dist/commands/layout/validate.js +4 -1
- package/dist/commands/login.js +1 -0
- package/dist/commands/logout.js +1 -0
- package/dist/commands/message-type/get.js +46 -3
- package/dist/commands/message-type/list.js +46 -3
- package/dist/commands/message-type/pull.js +6 -4
- package/dist/commands/message-type/push.js +4 -3
- package/dist/commands/message-type/validate.js +4 -3
- package/dist/commands/partial/get.js +46 -1
- package/dist/commands/partial/list.js +46 -1
- package/dist/commands/partial/pull.js +6 -2
- package/dist/commands/partial/push.js +4 -1
- package/dist/commands/partial/validate.js +6 -1
- package/dist/commands/pull.js +28 -8
- package/dist/commands/push.js +27 -8
- package/dist/commands/translation/get.js +5 -1
- package/dist/commands/translation/list.js +5 -1
- package/dist/commands/translation/pull.js +8 -3
- package/dist/commands/translation/push.js +4 -1
- package/dist/commands/translation/validate.js +4 -1
- package/dist/commands/workflow/activate.js +47 -3
- package/dist/commands/workflow/generate-types.js +4 -1
- package/dist/commands/workflow/get.js +9 -4
- package/dist/commands/workflow/list.js +5 -1
- package/dist/commands/workflow/pull.js +6 -2
- package/dist/commands/workflow/push.js +4 -1
- package/dist/commands/workflow/run.js +46 -2
- package/dist/commands/workflow/validate.js +4 -1
- package/dist/lib/api-v1.js +35 -12
- package/dist/lib/helpers/arg.js +6 -5
- package/dist/lib/helpers/branch.js +124 -0
- package/dist/lib/helpers/command.js +14 -0
- package/dist/lib/helpers/error.js +5 -0
- package/dist/lib/helpers/flag.js +23 -0
- package/dist/lib/helpers/git.js +25 -0
- package/dist/lib/helpers/request.js +1 -1
- package/dist/lib/helpers/string.js +4 -0
- package/dist/lib/marshal/commit/index.js +0 -1
- package/dist/lib/marshal/translation/helpers.js +1 -1
- package/dist/lib/resources.js +6 -1
- package/dist/lib/urls.js +4 -0
- package/oclif.manifest.json +414 -50
- package/package.json +15 -5
- package/dist/commands/ping.js +0 -37
- package/dist/lib/marshal/commit/types.js +0 -5
|
@@ -10,8 +10,10 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _date = require("../../lib/helpers/date");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
16
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
15
17
|
const _request = require("../../lib/helpers/request");
|
|
16
18
|
const _ux = require("../../lib/helpers/ux");
|
|
17
19
|
function _define_property(obj, key, value) {
|
|
@@ -32,6 +34,47 @@ function _interop_require_default(obj) {
|
|
|
32
34
|
default: obj
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
38
|
+
if (typeof WeakMap !== "function") return null;
|
|
39
|
+
var cacheBabelInterop = new WeakMap();
|
|
40
|
+
var cacheNodeInterop = new WeakMap();
|
|
41
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
42
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
43
|
+
})(nodeInterop);
|
|
44
|
+
}
|
|
45
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
46
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
50
|
+
return {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
55
|
+
if (cache && cache.has(obj)) {
|
|
56
|
+
return cache.get(obj);
|
|
57
|
+
}
|
|
58
|
+
var newObj = {
|
|
59
|
+
__proto__: null
|
|
60
|
+
};
|
|
61
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
62
|
+
for(var key in obj){
|
|
63
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
64
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
65
|
+
if (desc && (desc.get || desc.set)) {
|
|
66
|
+
Object.defineProperty(newObj, key, desc);
|
|
67
|
+
} else {
|
|
68
|
+
newObj[key] = obj[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
newObj.default = obj;
|
|
73
|
+
if (cache) {
|
|
74
|
+
cache.set(obj, newObj);
|
|
75
|
+
}
|
|
76
|
+
return newObj;
|
|
77
|
+
}
|
|
35
78
|
class PartialGet extends _basecommand.default {
|
|
36
79
|
async run() {
|
|
37
80
|
_ux.spinner.start("‣ Loading");
|
|
@@ -55,7 +98,8 @@ class PartialGet extends _basecommand.default {
|
|
|
55
98
|
const { partialKey } = this.props.args;
|
|
56
99
|
const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
57
100
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
58
|
-
|
|
101
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
102
|
+
this.log(`‣ Showing partial \`${partialKey}\` in ${scope} ${qualifier}\n`);
|
|
59
103
|
/*
|
|
60
104
|
* Partial table
|
|
61
105
|
*/ const rows = [
|
|
@@ -112,6 +156,7 @@ _define_property(PartialGet, "flags", {
|
|
|
112
156
|
default: "development",
|
|
113
157
|
summary: "The environment to use."
|
|
114
158
|
}),
|
|
159
|
+
branch: _flag.branch,
|
|
115
160
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
116
161
|
summary: "Hide any uncommitted changes."
|
|
117
162
|
})
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _date = require("../../lib/helpers/date");
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
14
16
|
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
15
17
|
const _page = require("../../lib/helpers/page");
|
|
16
18
|
const _request = require("../../lib/helpers/request");
|
|
@@ -32,6 +34,47 @@ function _interop_require_default(obj) {
|
|
|
32
34
|
default: obj
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
38
|
+
if (typeof WeakMap !== "function") return null;
|
|
39
|
+
var cacheBabelInterop = new WeakMap();
|
|
40
|
+
var cacheNodeInterop = new WeakMap();
|
|
41
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
42
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
43
|
+
})(nodeInterop);
|
|
44
|
+
}
|
|
45
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
46
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
50
|
+
return {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
55
|
+
if (cache && cache.has(obj)) {
|
|
56
|
+
return cache.get(obj);
|
|
57
|
+
}
|
|
58
|
+
var newObj = {
|
|
59
|
+
__proto__: null
|
|
60
|
+
};
|
|
61
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
62
|
+
for(var key in obj){
|
|
63
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
64
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
65
|
+
if (desc && (desc.get || desc.set)) {
|
|
66
|
+
Object.defineProperty(newObj, key, desc);
|
|
67
|
+
} else {
|
|
68
|
+
newObj[key] = obj[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
newObj.default = obj;
|
|
73
|
+
if (cache) {
|
|
74
|
+
cache.set(obj, newObj);
|
|
75
|
+
}
|
|
76
|
+
return newObj;
|
|
77
|
+
}
|
|
35
78
|
class PartialList extends _basecommand.default {
|
|
36
79
|
async run() {
|
|
37
80
|
const resp = await this.request();
|
|
@@ -51,7 +94,8 @@ class PartialList extends _basecommand.default {
|
|
|
51
94
|
const { entries } = data;
|
|
52
95
|
const { environment: env, "hide-uncommitted-changes": committedOnly } = this.props.flags;
|
|
53
96
|
const qualifier = env === "development" && !committedOnly ? "(including uncommitted)" : "";
|
|
54
|
-
|
|
97
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
98
|
+
this.log(`‣ Showing ${entries.length} partials in ${scope} ${qualifier}\n`);
|
|
55
99
|
/*
|
|
56
100
|
* Partials list table
|
|
57
101
|
*/ _core.ux.table(entries, {
|
|
@@ -95,6 +139,7 @@ _define_property(PartialList, "flags", {
|
|
|
95
139
|
default: "development",
|
|
96
140
|
summary: "The environment to use."
|
|
97
141
|
}),
|
|
142
|
+
branch: _flag.branch,
|
|
98
143
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
99
144
|
summary: "Hide any uncommitted changes."
|
|
100
145
|
}),
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
12
12
|
const _core = require("@oclif/core");
|
|
13
13
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
14
|
+
const _command = require("../../lib/helpers/command");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
15
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
16
17
|
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
@@ -110,7 +111,8 @@ class PartialPull extends _basecommand.default {
|
|
|
110
111
|
});
|
|
111
112
|
await _partial.writePartialDirFromData(dirContext, resp.data);
|
|
112
113
|
const action = dirContext.exists ? "updated" : "created";
|
|
113
|
-
|
|
114
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
115
|
+
this.log(`‣ Successfully ${action} \`${dirContext.key}\` at ${dirContext.abspath} using ${scope}`);
|
|
114
116
|
}
|
|
115
117
|
// Pull all partials
|
|
116
118
|
async pullAllPartials() {
|
|
@@ -128,7 +130,8 @@ class PartialPull extends _basecommand.default {
|
|
|
128
130
|
await _partial.writePartialsIndexDir(targetDirCtx, partials);
|
|
129
131
|
_ux.spinner.stop();
|
|
130
132
|
const action = targetDirCtx.exists ? "updated" : "created";
|
|
131
|
-
|
|
133
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
134
|
+
this.log(`‣ Successfully ${action} the partials directory at ${targetDirCtx.abspath} using ${scope}`);
|
|
132
135
|
}
|
|
133
136
|
async listAllPartials(pageParams = {}, partialsFetchedSoFar = []) {
|
|
134
137
|
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
@@ -186,6 +189,7 @@ _define_property(PartialPull, "flags", {
|
|
|
186
189
|
default: "development",
|
|
187
190
|
summary: "The environment to use."
|
|
188
191
|
}),
|
|
192
|
+
branch: _flag.branch,
|
|
189
193
|
all: _core.Flags.boolean({
|
|
190
194
|
summary: "Whether to pull all partials from the specified environment."
|
|
191
195
|
}),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _const = require("../../lib/helpers/const");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
15
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
@@ -130,7 +131,8 @@ class PartialPush extends _basecommand.default {
|
|
|
130
131
|
// 4. Display a success message.
|
|
131
132
|
const partialKeys = partials.map((l)=>l.key);
|
|
132
133
|
const actioned = flags.commit ? "pushed and committed" : "pushed";
|
|
133
|
-
|
|
134
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
135
|
+
this.log(`‣ Successfully ${actioned} ${partials.length} partial(s) to ${scope}:\n` + (0, _string.indentString)(partialKeys.join("\n"), 4));
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
_define_property(PartialPush, "summary", "Push one or more partials from a local file system to Knock.");
|
|
@@ -142,6 +144,7 @@ _define_property(PartialPush, "flags", {
|
|
|
142
144
|
_const.KnockEnv.Development
|
|
143
145
|
]
|
|
144
146
|
}),
|
|
147
|
+
branch: _flag.branch,
|
|
145
148
|
all: _core.Flags.boolean({
|
|
146
149
|
summary: "Whether to push all partials from the target directory."
|
|
147
150
|
}),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _const = require("../../lib/helpers/const");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
15
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
@@ -102,7 +103,10 @@ class PartialValidate extends _basecommand.default {
|
|
|
102
103
|
_ux.spinner.stop();
|
|
103
104
|
// 3. Display a success message.
|
|
104
105
|
const partialKeys = partials.map((p)=>p.key);
|
|
105
|
-
|
|
106
|
+
const scope = (0, _command.formatCommandScope)({
|
|
107
|
+
...this.props.flags
|
|
108
|
+
});
|
|
109
|
+
this.log(`‣ Successfully validated ${partials.length} partial(s) using ${scope}:\n` + (0, _string.indentString)(partialKeys.join("\n"), 4));
|
|
106
110
|
}
|
|
107
111
|
static async validateAll(api, props, partials) {
|
|
108
112
|
// TODO: Throw an error if a non validation error (e.g. authentication error)
|
|
@@ -129,6 +133,7 @@ _define_property(PartialValidate, "flags", {
|
|
|
129
133
|
_const.KnockEnv.Development
|
|
130
134
|
]
|
|
131
135
|
}),
|
|
136
|
+
branch: _flag.branch,
|
|
132
137
|
all: _core.Flags.boolean({
|
|
133
138
|
summary: "Whether to validate all partials from the target directory."
|
|
134
139
|
}),
|
package/dist/commands/pull.js
CHANGED
|
@@ -14,10 +14,12 @@ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../lib/base
|
|
|
14
14
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../lib/helpers/flag"));
|
|
15
15
|
const _ux = require("../lib/helpers/ux");
|
|
16
16
|
const _resources = require("../lib/resources");
|
|
17
|
-
const _pull = /*#__PURE__*/ _interop_require_default(require("./
|
|
18
|
-
const _pull1 = /*#__PURE__*/ _interop_require_default(require("./
|
|
19
|
-
const _pull2 = /*#__PURE__*/ _interop_require_default(require("./
|
|
20
|
-
const _pull3 = /*#__PURE__*/ _interop_require_default(require("./
|
|
17
|
+
const _pull = /*#__PURE__*/ _interop_require_default(require("./guide/pull"));
|
|
18
|
+
const _pull1 = /*#__PURE__*/ _interop_require_default(require("./layout/pull"));
|
|
19
|
+
const _pull2 = /*#__PURE__*/ _interop_require_default(require("./message-type/pull"));
|
|
20
|
+
const _pull3 = /*#__PURE__*/ _interop_require_default(require("./partial/pull"));
|
|
21
|
+
const _pull4 = /*#__PURE__*/ _interop_require_default(require("./translation/pull"));
|
|
22
|
+
const _pull5 = /*#__PURE__*/ _interop_require_default(require("./workflow/pull"));
|
|
21
23
|
function _define_property(obj, key, value) {
|
|
22
24
|
if (key in obj) {
|
|
23
25
|
Object.defineProperty(obj, key, {
|
|
@@ -88,6 +90,10 @@ class Pull extends _basecommand.default {
|
|
|
88
90
|
"--all",
|
|
89
91
|
"--environment",
|
|
90
92
|
flags.environment,
|
|
93
|
+
...flags.branch ? [
|
|
94
|
+
"--branch",
|
|
95
|
+
flags.branch
|
|
96
|
+
] : [],
|
|
91
97
|
...flags["hide-uncommitted-changes"] ? [
|
|
92
98
|
"--hide-uncommitted-changes"
|
|
93
99
|
] : [],
|
|
@@ -110,6 +116,7 @@ _define_property(Pull, "flags", {
|
|
|
110
116
|
default: "development",
|
|
111
117
|
summary: "The environment to use."
|
|
112
118
|
}),
|
|
119
|
+
branch: _flag.branch,
|
|
113
120
|
"knock-dir": _flag.dirPath({
|
|
114
121
|
summary: "The target directory path to pull all resources into.",
|
|
115
122
|
required: true
|
|
@@ -125,29 +132,42 @@ const runResourcePullCommand = async (resourceType, targetDirCtx, args)=>{
|
|
|
125
132
|
const subdirPath = _nodepath.resolve(targetDirCtx.abspath, _resources.RESOURCE_SUBDIRS[resourceType]);
|
|
126
133
|
switch(resourceType){
|
|
127
134
|
case "email_layout":
|
|
128
|
-
return
|
|
135
|
+
return _pull1.default.run([
|
|
129
136
|
...args,
|
|
130
137
|
"--layouts-dir",
|
|
131
138
|
subdirPath
|
|
132
139
|
]);
|
|
133
140
|
case "partial":
|
|
134
|
-
return
|
|
141
|
+
return _pull3.default.run([
|
|
135
142
|
...args,
|
|
136
143
|
"--partials-dir",
|
|
137
144
|
subdirPath
|
|
138
145
|
]);
|
|
146
|
+
// TODO(KNO-9451): Include translation in the knock pull
|
|
139
147
|
case "translation":
|
|
140
|
-
return
|
|
148
|
+
return _pull4.default.run([
|
|
141
149
|
...args,
|
|
142
150
|
"--translations-dir",
|
|
143
151
|
subdirPath
|
|
144
152
|
]);
|
|
145
153
|
case "workflow":
|
|
146
|
-
return
|
|
154
|
+
return _pull5.default.run([
|
|
147
155
|
...args,
|
|
148
156
|
"--workflows-dir",
|
|
149
157
|
subdirPath
|
|
150
158
|
]);
|
|
159
|
+
case "message_type":
|
|
160
|
+
return _pull2.default.run([
|
|
161
|
+
...args,
|
|
162
|
+
"--message-types-dir",
|
|
163
|
+
subdirPath
|
|
164
|
+
]);
|
|
165
|
+
case "guide":
|
|
166
|
+
return _pull.default.run([
|
|
167
|
+
...args,
|
|
168
|
+
"--guides-dir",
|
|
169
|
+
subdirPath
|
|
170
|
+
]);
|
|
151
171
|
default:
|
|
152
172
|
{
|
|
153
173
|
const invalidResourceType = resourceType;
|
package/dist/commands/push.js
CHANGED
|
@@ -15,10 +15,12 @@ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../lib/base
|
|
|
15
15
|
const _const = require("../lib/helpers/const");
|
|
16
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../lib/helpers/flag"));
|
|
17
17
|
const _resources = require("../lib/resources");
|
|
18
|
-
const _push = /*#__PURE__*/ _interop_require_default(require("./
|
|
19
|
-
const _push1 = /*#__PURE__*/ _interop_require_default(require("./
|
|
20
|
-
const _push2 = /*#__PURE__*/ _interop_require_default(require("./
|
|
21
|
-
const _push3 = /*#__PURE__*/ _interop_require_default(require("./
|
|
18
|
+
const _push = /*#__PURE__*/ _interop_require_default(require("./guide/push"));
|
|
19
|
+
const _push1 = /*#__PURE__*/ _interop_require_default(require("./layout/push"));
|
|
20
|
+
const _push2 = /*#__PURE__*/ _interop_require_default(require("./message-type/push"));
|
|
21
|
+
const _push3 = /*#__PURE__*/ _interop_require_default(require("./partial/push"));
|
|
22
|
+
const _push4 = /*#__PURE__*/ _interop_require_default(require("./translation/push"));
|
|
23
|
+
const _push5 = /*#__PURE__*/ _interop_require_default(require("./workflow/push"));
|
|
22
24
|
function _define_property(obj, key, value) {
|
|
23
25
|
if (key in obj) {
|
|
24
26
|
Object.defineProperty(obj, key, {
|
|
@@ -89,6 +91,10 @@ class Push extends _basecommand.default {
|
|
|
89
91
|
"--all",
|
|
90
92
|
"--environment",
|
|
91
93
|
flags.environment,
|
|
94
|
+
...flags.branch ? [
|
|
95
|
+
"--branch",
|
|
96
|
+
flags.branch
|
|
97
|
+
] : [],
|
|
92
98
|
...flags["service-token"] ? [
|
|
93
99
|
"--service-token",
|
|
94
100
|
flags["service-token"]
|
|
@@ -120,6 +126,7 @@ _define_property(Push, "flags", {
|
|
|
120
126
|
_const.KnockEnv.Development
|
|
121
127
|
]
|
|
122
128
|
}),
|
|
129
|
+
branch: _flag.branch,
|
|
123
130
|
"knock-dir": _flag.dirPath({
|
|
124
131
|
summary: "The target directory path to find all resources to push.",
|
|
125
132
|
required: true
|
|
@@ -143,29 +150,41 @@ const runResourcePushCommand = async (resourceType, targetDirCtx, args)=>{
|
|
|
143
150
|
}
|
|
144
151
|
switch(resourceType){
|
|
145
152
|
case "email_layout":
|
|
146
|
-
return
|
|
153
|
+
return _push1.default.run([
|
|
147
154
|
...args,
|
|
148
155
|
"--layouts-dir",
|
|
149
156
|
subdirPath
|
|
150
157
|
]);
|
|
151
158
|
case "partial":
|
|
152
|
-
return
|
|
159
|
+
return _push3.default.run([
|
|
153
160
|
...args,
|
|
154
161
|
"--partials-dir",
|
|
155
162
|
subdirPath
|
|
156
163
|
]);
|
|
157
164
|
case "translation":
|
|
158
|
-
return
|
|
165
|
+
return _push4.default.run([
|
|
159
166
|
...args,
|
|
160
167
|
"--translations-dir",
|
|
161
168
|
subdirPath
|
|
162
169
|
]);
|
|
163
170
|
case "workflow":
|
|
164
|
-
return
|
|
171
|
+
return _push5.default.run([
|
|
165
172
|
...args,
|
|
166
173
|
"--workflows-dir",
|
|
167
174
|
subdirPath
|
|
168
175
|
]);
|
|
176
|
+
case "message_type":
|
|
177
|
+
return _push2.default.run([
|
|
178
|
+
...args,
|
|
179
|
+
"--message-types-dir",
|
|
180
|
+
subdirPath
|
|
181
|
+
]);
|
|
182
|
+
case "guide":
|
|
183
|
+
return _push.default.run([
|
|
184
|
+
...args,
|
|
185
|
+
"--guides-dir",
|
|
186
|
+
subdirPath
|
|
187
|
+
]);
|
|
169
188
|
default:
|
|
170
189
|
{
|
|
171
190
|
const invalidResourceType = resourceType;
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _date = require("../../lib/helpers/date");
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
14
16
|
const _request = require("../../lib/helpers/request");
|
|
15
17
|
const _translation = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/translation"));
|
|
16
18
|
function _define_property(obj, key, value) {
|
|
@@ -87,7 +89,8 @@ class TranslationGet extends _basecommand.default {
|
|
|
87
89
|
const { translationRef } = this.props.args;
|
|
88
90
|
const { environment: env, "hide-uncommitted-changes": commitedOnly, format } = this.props.flags;
|
|
89
91
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
90
|
-
|
|
92
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
93
|
+
this.log(`‣ Showing translation \`${translationRef}\` in ${scope} ${qualifier}\n`);
|
|
91
94
|
/*
|
|
92
95
|
* Translation table
|
|
93
96
|
*/ const rows = [
|
|
@@ -136,6 +139,7 @@ _define_property(TranslationGet, "flags", {
|
|
|
136
139
|
default: "development",
|
|
137
140
|
summary: "The environment to use."
|
|
138
141
|
}),
|
|
142
|
+
branch: _flag.branch,
|
|
139
143
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
140
144
|
summary: "Hide any uncommitted changes."
|
|
141
145
|
}),
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _date = require("../../lib/helpers/date");
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
14
16
|
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
15
17
|
const _page = require("../../lib/helpers/page");
|
|
16
18
|
const _request = require("../../lib/helpers/request");
|
|
@@ -93,7 +95,8 @@ class TranslationList extends _basecommand.default {
|
|
|
93
95
|
const { entries } = data;
|
|
94
96
|
const { environment: env, "hide-uncommitted-changes": committedOnly } = this.props.flags;
|
|
95
97
|
const qualifier = env === "development" && !committedOnly ? "(including uncommitted)" : "";
|
|
96
|
-
|
|
98
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
99
|
+
this.log(`‣ Showing ${entries.length} translations in ${scope} ${qualifier}\n`);
|
|
97
100
|
/*
|
|
98
101
|
* Translations list table
|
|
99
102
|
*/ _core.ux.table(entries, {
|
|
@@ -139,6 +142,7 @@ _define_property(TranslationList, "flags", {
|
|
|
139
142
|
default: "development",
|
|
140
143
|
summary: "The environment to use."
|
|
141
144
|
}),
|
|
145
|
+
branch: _flag.branch,
|
|
142
146
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
143
147
|
summary: "Hide any uncommitted changes."
|
|
144
148
|
}),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _error = require("../../lib/helpers/error");
|
|
14
15
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
15
16
|
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
@@ -106,7 +107,8 @@ class TranslationPull extends _basecommand.default {
|
|
|
106
107
|
format: flags.format
|
|
107
108
|
});
|
|
108
109
|
const actioned = targetCtx.exists ? "updated" : "created";
|
|
109
|
-
|
|
110
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
111
|
+
this.log(`‣ Successfully ${actioned} \`${targetCtx.ref}\` at ${targetCtx.abspath} using ${scope}`);
|
|
110
112
|
}
|
|
111
113
|
/*
|
|
112
114
|
* Pull all translations for a locale (using TranslationDirContext)
|
|
@@ -127,7 +129,8 @@ class TranslationPull extends _basecommand.default {
|
|
|
127
129
|
});
|
|
128
130
|
_ux.spinner.stop();
|
|
129
131
|
const actioned = targetCtx.exists ? "updated" : "created";
|
|
130
|
-
|
|
132
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
133
|
+
this.log(`‣ Successfully ${actioned} the \`${targetCtx.key}\` translations directory at ${targetCtx.abspath} using ${scope}`);
|
|
131
134
|
}
|
|
132
135
|
/*
|
|
133
136
|
* Pull all translations (using DirContext)
|
|
@@ -144,7 +147,8 @@ class TranslationPull extends _basecommand.default {
|
|
|
144
147
|
});
|
|
145
148
|
_ux.spinner.stop();
|
|
146
149
|
const action = targetCtx.exists ? "updated" : "created";
|
|
147
|
-
|
|
150
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
151
|
+
this.log(`‣ Successfully ${action} the translations directory at ${targetCtx.abspath} using ${scope}`);
|
|
148
152
|
}
|
|
149
153
|
async listAllTranslations(filters = {}, pageParams = {}, translationsFetchedSoFar = []) {
|
|
150
154
|
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
@@ -174,6 +178,7 @@ _define_property(TranslationPull, "flags", {
|
|
|
174
178
|
default: "development",
|
|
175
179
|
summary: "The environment to use."
|
|
176
180
|
}),
|
|
181
|
+
branch: _flag.branch,
|
|
177
182
|
all: _core.Flags.boolean({
|
|
178
183
|
summary: "Whether to pull all translations from the specified environment."
|
|
179
184
|
}),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _const = require("../../lib/helpers/const");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
15
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
@@ -119,7 +120,8 @@ class TranslationPush extends _basecommand.default {
|
|
|
119
120
|
// 4. Display a success message.
|
|
120
121
|
const handledRefs = translations.map((t)=>t.ref);
|
|
121
122
|
const actioned = flags.commit ? "pushed and committed" : "pushed";
|
|
122
|
-
|
|
123
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
124
|
+
this.log(`‣ Successfully ${actioned} ${translations.length} translation(s) to ${scope}:\n` + (0, _string.indentString)(handledRefs.join("\n"), 4));
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
_define_property(TranslationPush, "summary", "Push one or more translations from a local file system to Knock.");
|
|
@@ -131,6 +133,7 @@ _define_property(TranslationPush, "flags", {
|
|
|
131
133
|
_const.KnockEnv.Development
|
|
132
134
|
]
|
|
133
135
|
}),
|
|
136
|
+
branch: _flag.branch,
|
|
134
137
|
all: _core.Flags.boolean({
|
|
135
138
|
summary: "Whether to push all translations from the target directory."
|
|
136
139
|
}),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
13
14
|
const _const = require("../../lib/helpers/const");
|
|
14
15
|
const _error = require("../../lib/helpers/error");
|
|
15
16
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
@@ -97,7 +98,8 @@ class TranslationValidate extends _basecommand.default {
|
|
|
97
98
|
}
|
|
98
99
|
_ux.spinner.stop();
|
|
99
100
|
const handledRefs = translations.map((t)=>t.ref);
|
|
100
|
-
|
|
101
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
102
|
+
this.log(`‣ Successfully validated ${translations.length} translation(s) using ${scope}:\n` + (0, _string.indentString)(handledRefs.join("\n"), 4));
|
|
101
103
|
}
|
|
102
104
|
static async validateAll(api, props, translations) {
|
|
103
105
|
// TODO: Throw if a non validation error (e.g. authentication error) instead
|
|
@@ -126,6 +128,7 @@ _define_property(TranslationValidate, "flags", {
|
|
|
126
128
|
_const.KnockEnv.Development
|
|
127
129
|
]
|
|
128
130
|
}),
|
|
131
|
+
branch: _flag.branch,
|
|
129
132
|
all: _core.Flags.boolean({
|
|
130
133
|
summary: "Whether to validate all translations from the target directory."
|
|
131
134
|
}),
|
|
@@ -10,7 +10,8 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
-
const
|
|
13
|
+
const _command = require("../../lib/helpers/command");
|
|
14
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
14
15
|
const _request = require("../../lib/helpers/request");
|
|
15
16
|
const _ux = require("../../lib/helpers/ux");
|
|
16
17
|
function _define_property(obj, key, value) {
|
|
@@ -31,12 +32,54 @@ function _interop_require_default(obj) {
|
|
|
31
32
|
default: obj
|
|
32
33
|
};
|
|
33
34
|
}
|
|
35
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
36
|
+
if (typeof WeakMap !== "function") return null;
|
|
37
|
+
var cacheBabelInterop = new WeakMap();
|
|
38
|
+
var cacheNodeInterop = new WeakMap();
|
|
39
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
40
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
41
|
+
})(nodeInterop);
|
|
42
|
+
}
|
|
43
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
44
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
45
|
+
return obj;
|
|
46
|
+
}
|
|
47
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
48
|
+
return {
|
|
49
|
+
default: obj
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
53
|
+
if (cache && cache.has(obj)) {
|
|
54
|
+
return cache.get(obj);
|
|
55
|
+
}
|
|
56
|
+
var newObj = {
|
|
57
|
+
__proto__: null
|
|
58
|
+
};
|
|
59
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
|
+
for(var key in obj){
|
|
61
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
62
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
63
|
+
if (desc && (desc.get || desc.set)) {
|
|
64
|
+
Object.defineProperty(newObj, key, desc);
|
|
65
|
+
} else {
|
|
66
|
+
newObj[key] = obj[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
newObj.default = obj;
|
|
71
|
+
if (cache) {
|
|
72
|
+
cache.set(obj, newObj);
|
|
73
|
+
}
|
|
74
|
+
return newObj;
|
|
75
|
+
}
|
|
34
76
|
class WorkflowActivate extends _basecommand.default {
|
|
35
77
|
async run() {
|
|
36
78
|
const { args, flags } = this.props;
|
|
37
79
|
// 1. Confirm before activating or deactivating the workflow, unless forced.
|
|
38
80
|
const action = flags.status ? "Activate" : "Deactivate";
|
|
39
|
-
const
|
|
81
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
82
|
+
const prompt = `${action} \`${args.workflowKey}\` workflow in ${scope}?`;
|
|
40
83
|
const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
|
|
41
84
|
if (!input) return;
|
|
42
85
|
// 2. Proceed to make a request to set the workflow status.
|
|
@@ -47,7 +90,7 @@ class WorkflowActivate extends _basecommand.default {
|
|
|
47
90
|
action: `‣ ${actioning}`
|
|
48
91
|
});
|
|
49
92
|
const actioned = flags.status ? "activated" : "deactivated";
|
|
50
|
-
this.log(`‣ Successfully ${actioned} \`${args.workflowKey}\` workflow in
|
|
93
|
+
this.log(`‣ Successfully ${actioned} \`${args.workflowKey}\` workflow in ${scope}`);
|
|
51
94
|
}
|
|
52
95
|
}
|
|
53
96
|
_define_property(WorkflowActivate, "summary", "Activate or deactivate a workflow in a given environment.");
|
|
@@ -65,6 +108,7 @@ _define_property(WorkflowActivate, "flags", {
|
|
|
65
108
|
required: true,
|
|
66
109
|
summary: "The environment to use."
|
|
67
110
|
}),
|
|
111
|
+
branch: _flag.branch,
|
|
68
112
|
status: (0, _flag.booleanStr)({
|
|
69
113
|
default: true,
|
|
70
114
|
summary: "The workflow active status to set."
|