@knocklabs/cli 0.2.1 → 0.2.2
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/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/command.js +14 -0
- package/dist/lib/helpers/flag.js +18 -0
- package/dist/lib/helpers/string.js +4 -0
- package/dist/lib/marshal/commit/index.js +0 -1
- package/dist/lib/resources.js +6 -1
- package/dist/lib/urls.js +4 -0
- package/oclif.manifest.json +316 -50
- package/package.json +13 -4
- package/dist/commands/ping.js +0 -37
- package/dist/lib/marshal/commit/types.js +0 -5
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."
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
const _core = require("@oclif/core");
|
|
12
12
|
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
13
13
|
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
14
|
+
const _command = require("../../lib/helpers/command");
|
|
14
15
|
const _const = require("../../lib/helpers/const");
|
|
15
16
|
const _error = require("../../lib/helpers/error");
|
|
16
17
|
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
@@ -101,7 +102,8 @@ class WorkflowGenerateTypes extends _basecommand.default {
|
|
|
101
102
|
}
|
|
102
103
|
// 3. Write the generated types to the output file.
|
|
103
104
|
await _fsextra.writeFile(flags["output-file"].abspath, result.lines.join("\n"));
|
|
104
|
-
|
|
105
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
106
|
+
this.log(`‣ Successfully generated types for ${workflowsWithValidTypes.length} workflow(s) using ${scope} and wrote them to ${flags["output-file"].abspath}`);
|
|
105
107
|
}
|
|
106
108
|
async listAllWorkflows(pageParams = {}, workflowsFetchedSoFar = []) {
|
|
107
109
|
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
@@ -132,6 +134,7 @@ _define_property(WorkflowGenerateTypes, "flags", {
|
|
|
132
134
|
summary: "Select the environment to generate types for.",
|
|
133
135
|
default: _const.KnockEnv.Development
|
|
134
136
|
}),
|
|
137
|
+
branch: _flag.branch,
|
|
135
138
|
"output-file": _flag.filePath({
|
|
136
139
|
summary: "The output file to write the generated types to. We currently support .ts, .rb, .go, .py files only. Your file extension will determine the target language for the generated types.",
|
|
137
140
|
required: true
|
|
@@ -10,13 +10,16 @@ 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 _string = require("../../lib/helpers/string");
|
|
17
19
|
const _ux = require("../../lib/helpers/ux");
|
|
18
20
|
const _conditions = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/conditions"));
|
|
19
21
|
const _workflow = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/workflow"));
|
|
22
|
+
const _urls = require("../../lib/urls");
|
|
20
23
|
function _define_property(obj, key, value) {
|
|
21
24
|
if (key in obj) {
|
|
22
25
|
Object.defineProperty(obj, key, {
|
|
@@ -103,9 +106,10 @@ class WorkflowGet extends _basecommand.default {
|
|
|
103
106
|
}
|
|
104
107
|
render(workflow, whoami) {
|
|
105
108
|
const { workflowKey } = this.props.args;
|
|
106
|
-
const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
109
|
+
const { environment: env, branch, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
107
110
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
108
|
-
|
|
111
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
112
|
+
this.log(`‣ Showing workflow \`${workflowKey}\` in ${scope} ${qualifier}\n`);
|
|
109
113
|
/*
|
|
110
114
|
* Workflow table
|
|
111
115
|
*/ const rows = [
|
|
@@ -191,9 +195,9 @@ class WorkflowGet extends _basecommand.default {
|
|
|
191
195
|
});
|
|
192
196
|
const hasTopLevelBranchStep = workflow.steps.some((step)=>step.type === _workflow.StepType.Branch);
|
|
193
197
|
const dashboardLinkMessage = hasTopLevelBranchStep ? `\n‣ This workflow has branches with nested steps, view the full workflow tree in the Knock Dashboard:` : `\n‣ View the full workflow in the Knock Dashboard:`;
|
|
194
|
-
const
|
|
198
|
+
const url = (0, _urls.viewWorkflowUrl)(this.sessionContext.dashboardOrigin, whoami.account_slug, branch !== null && branch !== void 0 ? branch : env, workflow.key);
|
|
195
199
|
this.log(dashboardLinkMessage);
|
|
196
|
-
this.log((0, _string.indentString)(
|
|
200
|
+
this.log((0, _string.indentString)(url, 2));
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
_define_property(WorkflowGet, "summary", "Display a single workflow from an environment.");
|
|
@@ -202,6 +206,7 @@ _define_property(WorkflowGet, "flags", {
|
|
|
202
206
|
default: "development",
|
|
203
207
|
summary: "The environment to use."
|
|
204
208
|
}),
|
|
209
|
+
branch: _flag.branch,
|
|
205
210
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
206
211
|
summary: "Hide any uncommitted changes."
|
|
207
212
|
})
|
|
@@ -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 WorkflowList extends _basecommand.default {
|
|
|
93
95
|
const { entries } = data;
|
|
94
96
|
const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
95
97
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
96
|
-
|
|
98
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
99
|
+
this.log(`‣ Showing ${entries.length} workflows in ${scope} ${qualifier}\n`);
|
|
97
100
|
/*
|
|
98
101
|
* Workflows list table
|
|
99
102
|
*/ _core.ux.table(entries, {
|
|
@@ -144,6 +147,7 @@ _define_property(WorkflowList, "flags", {
|
|
|
144
147
|
default: "development",
|
|
145
148
|
summary: "The environment to use."
|
|
146
149
|
}),
|
|
150
|
+
branch: _flag.branch,
|
|
147
151
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
148
152
|
summary: "Hide any uncommitted changes."
|
|
149
153
|
}),
|
|
@@ -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");
|
|
@@ -114,7 +115,8 @@ class WorkflowPull extends _basecommand.default {
|
|
|
114
115
|
// 3. Write the fetched workflow to create or update the workflow directory.
|
|
115
116
|
await _workflow.writeWorkflowDirFromData(dirContext, resp.data);
|
|
116
117
|
const action = dirContext.exists ? "updated" : "created";
|
|
117
|
-
|
|
118
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
119
|
+
this.log(`‣ Successfully ${action} \`${dirContext.key}\` at ${dirContext.abspath} using ${scope}`);
|
|
118
120
|
}
|
|
119
121
|
async getWorkflowDirContext() {
|
|
120
122
|
const { workflowKey } = this.props.args;
|
|
@@ -163,7 +165,8 @@ class WorkflowPull extends _basecommand.default {
|
|
|
163
165
|
await _workflow.writeWorkflowsIndexDir(targetDirCtx, workflows);
|
|
164
166
|
_ux.spinner.stop();
|
|
165
167
|
const action = targetDirCtx.exists ? "updated" : "created";
|
|
166
|
-
|
|
168
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
169
|
+
this.log(`‣ Successfully ${action} the workflows directory at ${targetDirCtx.abspath} using ${scope}`);
|
|
167
170
|
}
|
|
168
171
|
async listAllWorkflows(pageParams = {}, workflowsFetchedSoFar = []) {
|
|
169
172
|
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
@@ -194,6 +197,7 @@ _define_property(WorkflowPull, "flags", {
|
|
|
194
197
|
default: "development",
|
|
195
198
|
summary: "The environment to use."
|
|
196
199
|
}),
|
|
200
|
+
branch: _flag.branch,
|
|
197
201
|
all: _core.Flags.boolean({
|
|
198
202
|
summary: "Whether to pull all workflows from the specified environment."
|
|
199
203
|
}),
|
|
@@ -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 WorkflowPush extends _basecommand.default {
|
|
|
130
131
|
// 4. Display a success message.
|
|
131
132
|
const workflowKeys = workflows.map((w)=>w.key);
|
|
132
133
|
const actioned = flags.commit ? "pushed and committed" : "pushed";
|
|
133
|
-
|
|
134
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
135
|
+
this.log(`‣ Successfully ${actioned} ${workflows.length} workflow(s) to ${scope}:\n` + (0, _string.indentString)(workflowKeys.join("\n"), 4));
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
_define_property(WorkflowPush, "summary", "Push one or more workflows from a local file system to Knock.");
|
|
@@ -142,6 +144,7 @@ _define_property(WorkflowPush, "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 workflows from the target directory."
|
|
147
150
|
}),
|
|
@@ -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 _string = require("../../lib/helpers/string");
|
|
16
17
|
function _define_property(obj, key, value) {
|
|
@@ -31,13 +32,55 @@ 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 WorkflowRun extends _basecommand.default {
|
|
35
77
|
async run() {
|
|
36
78
|
const { args, flags } = this.props;
|
|
37
79
|
const resp = await (0, _request.withSpinner)(()=>this.apiV1.runWorkflow(this.props), {
|
|
38
80
|
action: "‣ Running"
|
|
39
81
|
});
|
|
40
|
-
|
|
82
|
+
const scope = (0, _command.formatCommandScope)(flags);
|
|
83
|
+
this.log(`‣ Successfully ran \`${args.workflowKey}\` workflow in ${scope}`);
|
|
41
84
|
this.log((0, _string.indentString)(`Workflow run id: ${resp.data.workflow_run_id}`, 4));
|
|
42
85
|
}
|
|
43
86
|
}
|
|
@@ -47,6 +90,7 @@ _define_property(WorkflowRun, "flags", {
|
|
|
47
90
|
default: "development",
|
|
48
91
|
summary: "The environment in which to run the workflow"
|
|
49
92
|
}),
|
|
93
|
+
branch: _flag.branch,
|
|
50
94
|
recipients: (0, _flag.maybeJsonStrAsList)({
|
|
51
95
|
required: true,
|
|
52
96
|
aliases: [
|