@knocklabs/cli 0.2.0 → 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 +56 -0
- package/dist/commands/branch/delete.js +60 -0
- package/dist/commands/branch/list.js +89 -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/whoami.js +7 -8
- 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 +57 -20
- package/dist/lib/helpers/arg.js +24 -0
- package/dist/lib/helpers/command.js +14 -0
- package/dist/lib/helpers/flag.js +18 -0
- package/dist/lib/helpers/request.js +48 -2
- package/dist/lib/helpers/string.js +4 -0
- package/dist/lib/marshal/commit/index.js +0 -1
- package/dist/lib/marshal/index.isomorphic.js +8 -4
- package/dist/lib/marshal/reusable-step/helpers.js +72 -0
- package/dist/lib/marshal/reusable-step/index.js +19 -0
- package/dist/lib/marshal/reusable-step/processor.isomorphic.js +86 -0
- package/dist/lib/marshal/{commit → reusable-step}/types.js +0 -1
- package/dist/lib/resources.js +6 -1
- package/dist/lib/urls.js +4 -0
- package/oclif.manifest.json +489 -50
- package/package.json +16 -5
- package/dist/commands/ping.js +0 -37
|
@@ -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: [
|
|
@@ -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,8 @@ class WorkflowValidate extends _basecommand.default {
|
|
|
102
103
|
_ux.spinner.stop();
|
|
103
104
|
// 3. Display a success message.
|
|
104
105
|
const workflowKeys = workflows.map((w)=>w.key);
|
|
105
|
-
|
|
106
|
+
const scope = (0, _command.formatCommandScope)(this.props.flags);
|
|
107
|
+
this.log(`‣ Successfully validated ${workflows.length} workflow(s) using ${scope}:\n` + (0, _string.indentString)(workflowKeys.join("\n"), 4));
|
|
106
108
|
}
|
|
107
109
|
static async validateAll(api, props, workflows) {
|
|
108
110
|
// TODO: Throw an error if a non validation error (e.g. authentication error)
|
|
@@ -129,6 +131,7 @@ _define_property(WorkflowValidate, "flags", {
|
|
|
129
131
|
_const.KnockEnv.Development
|
|
130
132
|
]
|
|
131
133
|
}),
|
|
134
|
+
branch: _flag.branch,
|
|
132
135
|
all: _core.Flags.boolean({
|
|
133
136
|
summary: "Whether to validate all workflows from the target directory."
|
|
134
137
|
}),
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return ApiV1;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _mgmt = /*#__PURE__*/ _interop_require_default(require("@knocklabs/mgmt"));
|
|
11
12
|
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
12
13
|
const _objectisomorphic = require("./helpers/object.isomorphic");
|
|
13
14
|
const _page = require("./helpers/page");
|
|
@@ -30,13 +31,15 @@ function _interop_require_default(obj) {
|
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
const API_VERSION = "v1";
|
|
34
|
+
/**
|
|
35
|
+
* KnockMgmt client requires a service token, but we set the Authorization
|
|
36
|
+
* request header directly, so use a placeholder when service token is not
|
|
37
|
+
* provided.
|
|
38
|
+
*/ const PLACEHOLDER_SERVICE_TOKEN = "placeholder-service-token";
|
|
33
39
|
class ApiV1 {
|
|
34
40
|
getToken(sessionContext) {
|
|
35
41
|
return sessionContext.session ? sessionContext.session.accessToken : sessionContext.token;
|
|
36
42
|
}
|
|
37
|
-
async ping() {
|
|
38
|
-
return this.get("/ping");
|
|
39
|
-
}
|
|
40
43
|
async whoami() {
|
|
41
44
|
return this.get("/whoami");
|
|
42
45
|
}
|
|
@@ -44,6 +47,7 @@ class ApiV1 {
|
|
|
44
47
|
async listWorkflows({ flags }) {
|
|
45
48
|
const params = (0, _objectisomorphic.prune)({
|
|
46
49
|
environment: flags.environment,
|
|
50
|
+
branch: flags.branch,
|
|
47
51
|
annotate: flags.annotate,
|
|
48
52
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
49
53
|
...(0, _page.toPageParams)(flags)
|
|
@@ -55,6 +59,7 @@ class ApiV1 {
|
|
|
55
59
|
async getWorkflow({ args, flags }) {
|
|
56
60
|
const params = (0, _objectisomorphic.prune)({
|
|
57
61
|
environment: flags.environment,
|
|
62
|
+
branch: flags.branch,
|
|
58
63
|
annotate: flags.annotate,
|
|
59
64
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
60
65
|
});
|
|
@@ -65,6 +70,7 @@ class ApiV1 {
|
|
|
65
70
|
async upsertWorkflow({ flags }, workflow) {
|
|
66
71
|
const params = (0, _objectisomorphic.prune)({
|
|
67
72
|
environment: flags.environment,
|
|
73
|
+
branch: flags.branch,
|
|
68
74
|
annotate: flags.annotate,
|
|
69
75
|
commit: flags.commit,
|
|
70
76
|
commit_message: flags["commit-message"]
|
|
@@ -78,7 +84,8 @@ class ApiV1 {
|
|
|
78
84
|
}
|
|
79
85
|
async validateWorkflow({ flags }, workflow) {
|
|
80
86
|
const params = (0, _objectisomorphic.prune)({
|
|
81
|
-
environment: flags.environment
|
|
87
|
+
environment: flags.environment,
|
|
88
|
+
branch: flags.branch
|
|
82
89
|
});
|
|
83
90
|
const data = {
|
|
84
91
|
workflow
|
|
@@ -90,6 +97,7 @@ class ApiV1 {
|
|
|
90
97
|
async activateWorkflow({ args, flags }) {
|
|
91
98
|
const params = (0, _objectisomorphic.prune)({
|
|
92
99
|
environment: flags.environment,
|
|
100
|
+
branch: flags.branch,
|
|
93
101
|
status: flags.status
|
|
94
102
|
});
|
|
95
103
|
return this.put(`/workflows/${args.workflowKey}/activate`, {}, {
|
|
@@ -98,7 +106,8 @@ class ApiV1 {
|
|
|
98
106
|
}
|
|
99
107
|
async runWorkflow({ args, flags }) {
|
|
100
108
|
const params = (0, _objectisomorphic.prune)({
|
|
101
|
-
environment: flags.environment
|
|
109
|
+
environment: flags.environment,
|
|
110
|
+
branch: flags.branch
|
|
102
111
|
});
|
|
103
112
|
const data = (0, _objectisomorphic.prune)({
|
|
104
113
|
recipients: flags.recipients,
|
|
@@ -114,6 +123,7 @@ class ApiV1 {
|
|
|
114
123
|
async listCommits({ flags }) {
|
|
115
124
|
const params = (0, _objectisomorphic.prune)({
|
|
116
125
|
environment: flags.environment,
|
|
126
|
+
branch: flags.branch,
|
|
117
127
|
promoted: flags.promoted,
|
|
118
128
|
resource_type: flags["resource-type"],
|
|
119
129
|
resource_id: flags["resource-id"],
|
|
@@ -123,12 +133,10 @@ class ApiV1 {
|
|
|
123
133
|
params
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
|
-
async getCommit({ args }) {
|
|
127
|
-
return this.get(`/commits/${args.id}`);
|
|
128
|
-
}
|
|
129
136
|
async commitAllChanges({ flags }) {
|
|
130
137
|
const params = (0, _objectisomorphic.prune)({
|
|
131
138
|
environment: flags.environment,
|
|
139
|
+
branch: flags.branch,
|
|
132
140
|
commit_message: flags["commit-message"]
|
|
133
141
|
});
|
|
134
142
|
return this.put(`/commits`, {}, {
|
|
@@ -150,6 +158,7 @@ class ApiV1 {
|
|
|
150
158
|
async listTranslations({ flags }, filters = {}) {
|
|
151
159
|
const params = (0, _objectisomorphic.prune)({
|
|
152
160
|
environment: flags.environment,
|
|
161
|
+
branch: flags.branch,
|
|
153
162
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
154
163
|
locale_code: filters.localeCode,
|
|
155
164
|
namespace: filters.namespace,
|
|
@@ -163,6 +172,7 @@ class ApiV1 {
|
|
|
163
172
|
async getTranslation({ flags }, translation) {
|
|
164
173
|
const params = (0, _objectisomorphic.prune)({
|
|
165
174
|
environment: flags.environment,
|
|
175
|
+
branch: flags.branch,
|
|
166
176
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
167
177
|
namespace: translation.namespace,
|
|
168
178
|
format: flags.format
|
|
@@ -174,6 +184,7 @@ class ApiV1 {
|
|
|
174
184
|
async upsertTranslation({ flags }, translation) {
|
|
175
185
|
const params = (0, _objectisomorphic.prune)({
|
|
176
186
|
environment: flags.environment,
|
|
187
|
+
branch: flags.branch,
|
|
177
188
|
commit: flags.commit,
|
|
178
189
|
commit_message: flags["commit-message"],
|
|
179
190
|
namespace: translation.namespace
|
|
@@ -187,6 +198,7 @@ class ApiV1 {
|
|
|
187
198
|
async validateTranslation({ flags }, translation) {
|
|
188
199
|
const params = (0, _objectisomorphic.prune)({
|
|
189
200
|
environment: flags.environment,
|
|
201
|
+
branch: flags.branch,
|
|
190
202
|
namespace: translation.namespace
|
|
191
203
|
});
|
|
192
204
|
const data = {
|
|
@@ -200,6 +212,7 @@ class ApiV1 {
|
|
|
200
212
|
async listEmailLayouts({ flags }) {
|
|
201
213
|
const params = (0, _objectisomorphic.prune)({
|
|
202
214
|
environment: flags.environment,
|
|
215
|
+
branch: flags.branch,
|
|
203
216
|
annotate: flags.annotate,
|
|
204
217
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
205
218
|
...(0, _page.toPageParams)(flags)
|
|
@@ -211,6 +224,7 @@ class ApiV1 {
|
|
|
211
224
|
async getEmailLayout({ args, flags }) {
|
|
212
225
|
const params = (0, _objectisomorphic.prune)({
|
|
213
226
|
environment: flags.environment,
|
|
227
|
+
branch: flags.branch,
|
|
214
228
|
annotate: flags.annotate,
|
|
215
229
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
216
230
|
});
|
|
@@ -221,6 +235,7 @@ class ApiV1 {
|
|
|
221
235
|
async upsertEmailLayout({ flags }, layout) {
|
|
222
236
|
const params = (0, _objectisomorphic.prune)({
|
|
223
237
|
environment: flags.environment,
|
|
238
|
+
branch: flags.branch,
|
|
224
239
|
annotate: flags.annotate,
|
|
225
240
|
commit: flags.commit,
|
|
226
241
|
commit_message: flags["commit-message"]
|
|
@@ -234,7 +249,8 @@ class ApiV1 {
|
|
|
234
249
|
}
|
|
235
250
|
async validateEmailLayout({ flags }, layout) {
|
|
236
251
|
const params = (0, _objectisomorphic.prune)({
|
|
237
|
-
environment: flags.environment
|
|
252
|
+
environment: flags.environment,
|
|
253
|
+
branch: flags.branch
|
|
238
254
|
});
|
|
239
255
|
const data = {
|
|
240
256
|
email_layout: layout
|
|
@@ -247,6 +263,7 @@ class ApiV1 {
|
|
|
247
263
|
async listPartials({ flags }) {
|
|
248
264
|
const params = (0, _objectisomorphic.prune)({
|
|
249
265
|
environment: flags.environment,
|
|
266
|
+
branch: flags.branch,
|
|
250
267
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
251
268
|
annotate: flags.annotate,
|
|
252
269
|
...(0, _page.toPageParams)(flags)
|
|
@@ -258,6 +275,7 @@ class ApiV1 {
|
|
|
258
275
|
async getPartial({ args, flags }) {
|
|
259
276
|
const params = (0, _objectisomorphic.prune)({
|
|
260
277
|
environment: flags.environment,
|
|
278
|
+
branch: flags.branch,
|
|
261
279
|
annotate: flags.annotate,
|
|
262
280
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
263
281
|
});
|
|
@@ -268,6 +286,7 @@ class ApiV1 {
|
|
|
268
286
|
async upsertPartial({ flags }, partial) {
|
|
269
287
|
const params = (0, _objectisomorphic.prune)({
|
|
270
288
|
environment: flags.environment,
|
|
289
|
+
branch: flags.branch,
|
|
271
290
|
annotate: flags.annotate,
|
|
272
291
|
commit: flags.commit,
|
|
273
292
|
commit_message: flags["commit-message"]
|
|
@@ -281,7 +300,8 @@ class ApiV1 {
|
|
|
281
300
|
}
|
|
282
301
|
async validatePartial({ flags }, partial) {
|
|
283
302
|
const params = (0, _objectisomorphic.prune)({
|
|
284
|
-
environment: flags.environment
|
|
303
|
+
environment: flags.environment,
|
|
304
|
+
branch: flags.branch
|
|
285
305
|
});
|
|
286
306
|
const data = {
|
|
287
307
|
partial
|
|
@@ -294,6 +314,7 @@ class ApiV1 {
|
|
|
294
314
|
async listMessageTypes({ flags }) {
|
|
295
315
|
const params = (0, _objectisomorphic.prune)({
|
|
296
316
|
environment: flags.environment,
|
|
317
|
+
branch: flags.branch,
|
|
297
318
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
298
319
|
annotate: flags.annotate,
|
|
299
320
|
...(0, _page.toPageParams)(flags)
|
|
@@ -305,6 +326,7 @@ class ApiV1 {
|
|
|
305
326
|
async getMessageType({ args, flags }) {
|
|
306
327
|
const params = (0, _objectisomorphic.prune)({
|
|
307
328
|
environment: flags.environment,
|
|
329
|
+
branch: flags.branch,
|
|
308
330
|
annotate: flags.annotate,
|
|
309
331
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
310
332
|
});
|
|
@@ -315,6 +337,7 @@ class ApiV1 {
|
|
|
315
337
|
async upsertMessageType({ flags }, messageType) {
|
|
316
338
|
const params = (0, _objectisomorphic.prune)({
|
|
317
339
|
environment: flags.environment,
|
|
340
|
+
branch: flags.branch,
|
|
318
341
|
annotate: flags.annotate,
|
|
319
342
|
commit: flags.commit,
|
|
320
343
|
commit_message: flags["commit-message"]
|
|
@@ -328,7 +351,8 @@ class ApiV1 {
|
|
|
328
351
|
}
|
|
329
352
|
async validateMessageType({ flags }, messageType) {
|
|
330
353
|
const params = (0, _objectisomorphic.prune)({
|
|
331
|
-
environment: flags.environment
|
|
354
|
+
environment: flags.environment,
|
|
355
|
+
branch: flags.branch
|
|
332
356
|
});
|
|
333
357
|
const data = {
|
|
334
358
|
message_type: messageType
|
|
@@ -341,6 +365,7 @@ class ApiV1 {
|
|
|
341
365
|
async listGuides({ flags }) {
|
|
342
366
|
const params = (0, _objectisomorphic.prune)({
|
|
343
367
|
environment: flags.environment,
|
|
368
|
+
branch: flags.branch,
|
|
344
369
|
annotate: flags.annotate,
|
|
345
370
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
346
371
|
include_json_schema: flags["include-json-schema"],
|
|
@@ -353,6 +378,7 @@ class ApiV1 {
|
|
|
353
378
|
async getGuide({ args, flags }) {
|
|
354
379
|
const params = (0, _objectisomorphic.prune)({
|
|
355
380
|
environment: flags.environment,
|
|
381
|
+
branch: flags.branch,
|
|
356
382
|
annotate: flags.annotate,
|
|
357
383
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
358
384
|
});
|
|
@@ -362,7 +388,8 @@ class ApiV1 {
|
|
|
362
388
|
}
|
|
363
389
|
async validateGuide({ flags }, guide) {
|
|
364
390
|
const params = (0, _objectisomorphic.prune)({
|
|
365
|
-
environment: flags.environment
|
|
391
|
+
environment: flags.environment,
|
|
392
|
+
branch: flags.branch
|
|
366
393
|
});
|
|
367
394
|
const data = {
|
|
368
395
|
guide
|
|
@@ -374,6 +401,7 @@ class ApiV1 {
|
|
|
374
401
|
async upsertGuide({ flags }, guide) {
|
|
375
402
|
const params = (0, _objectisomorphic.prune)({
|
|
376
403
|
environment: flags.environment,
|
|
404
|
+
branch: flags.branch,
|
|
377
405
|
annotate: flags.annotate,
|
|
378
406
|
commit: flags.commit,
|
|
379
407
|
commit_message: flags["commit-message"]
|
|
@@ -388,6 +416,7 @@ class ApiV1 {
|
|
|
388
416
|
async activateGuide({ args, flags }) {
|
|
389
417
|
const params = (0, _objectisomorphic.prune)({
|
|
390
418
|
environment: flags.environment,
|
|
419
|
+
branch: flags.branch,
|
|
391
420
|
status: flags.status,
|
|
392
421
|
from: flags.from,
|
|
393
422
|
until: flags.until
|
|
@@ -406,21 +435,29 @@ class ApiV1 {
|
|
|
406
435
|
constructor(sessionContext, config){
|
|
407
436
|
var _sessionContext_session;
|
|
408
437
|
_define_property(this, "client", void 0);
|
|
438
|
+
_define_property(this, "mgmtClient", void 0);
|
|
409
439
|
const baseURL = sessionContext.apiOrigin;
|
|
410
440
|
const token = this.getToken(sessionContext);
|
|
411
441
|
var _sessionContext_session_clientId;
|
|
442
|
+
const headers = {
|
|
443
|
+
// Used to authenticate the request to the API.
|
|
444
|
+
Authorization: `Bearer ${token}`,
|
|
445
|
+
// Used in conjunction with the JWT access token, to allow the OAuth server to
|
|
446
|
+
// verify the client ID of the OAuth client that issued the access token.
|
|
447
|
+
"x-knock-client-id": (_sessionContext_session_clientId = (_sessionContext_session = sessionContext.session) === null || _sessionContext_session === void 0 ? void 0 : _sessionContext_session.clientId) !== null && _sessionContext_session_clientId !== void 0 ? _sessionContext_session_clientId : undefined,
|
|
448
|
+
"User-Agent": `${config.userAgent}`
|
|
449
|
+
};
|
|
412
450
|
this.client = _axios.default.create({
|
|
413
451
|
baseURL,
|
|
414
|
-
headers
|
|
415
|
-
// Used to authenticate the request to the API.
|
|
416
|
-
Authorization: `Bearer ${token}`,
|
|
417
|
-
// Used in conjunction with the JWT access token, to allow the OAuth server to
|
|
418
|
-
// verify the client ID of the OAuth client that issued the access token.
|
|
419
|
-
"x-knock-client-id": (_sessionContext_session_clientId = (_sessionContext_session = sessionContext.session) === null || _sessionContext_session === void 0 ? void 0 : _sessionContext_session.clientId) !== null && _sessionContext_session_clientId !== void 0 ? _sessionContext_session_clientId : undefined,
|
|
420
|
-
"User-Agent": `${config.userAgent}`
|
|
421
|
-
},
|
|
452
|
+
headers,
|
|
422
453
|
// Don't reject the promise based on a response status code.
|
|
423
454
|
validateStatus: null
|
|
424
455
|
});
|
|
456
|
+
// This should eventually replace the Axios client
|
|
457
|
+
this.mgmtClient = new _mgmt.default({
|
|
458
|
+
serviceToken: sessionContext.token || PLACEHOLDER_SERVICE_TOKEN,
|
|
459
|
+
baseURL,
|
|
460
|
+
defaultHeaders: headers
|
|
461
|
+
});
|
|
425
462
|
}
|
|
426
463
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "CustomArgs", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return CustomArgs;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@oclif/core");
|
|
12
|
+
const _string = require("./string");
|
|
13
|
+
const slug = _core.Args.custom({
|
|
14
|
+
parse: async (str)=>{
|
|
15
|
+
const slugifiedInput = (0, _string.slugify)(str);
|
|
16
|
+
if (!slugifiedInput) {
|
|
17
|
+
throw new Error("Invalid slug provided");
|
|
18
|
+
}
|
|
19
|
+
return slugifiedInput;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const CustomArgs = {
|
|
23
|
+
slug
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatCommandScope", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return formatCommandScope;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const formatCommandScope = (flags)=>{
|
|
12
|
+
const { environment, branch } = flags;
|
|
13
|
+
return `\`${branch !== null && branch !== void 0 ? branch : environment}\` ${branch ? "branch" : "environment"}`;
|
|
14
|
+
};
|
package/dist/lib/helpers/flag.js
CHANGED
|
@@ -12,6 +12,9 @@ _export(exports, {
|
|
|
12
12
|
get booleanStr () {
|
|
13
13
|
return booleanStr;
|
|
14
14
|
},
|
|
15
|
+
get branch () {
|
|
16
|
+
return branch;
|
|
17
|
+
},
|
|
15
18
|
get dirPath () {
|
|
16
19
|
return dirPath;
|
|
17
20
|
},
|
|
@@ -32,6 +35,7 @@ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
|
32
35
|
const _core = require("@oclif/core");
|
|
33
36
|
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
34
37
|
const _json = require("./json");
|
|
38
|
+
const _string = require("./string");
|
|
35
39
|
function _getRequireWildcardCache(nodeInterop) {
|
|
36
40
|
if (typeof WeakMap !== "function") return null;
|
|
37
41
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -131,3 +135,17 @@ const maybeJsonStrAsList = _core.Flags.custom({
|
|
|
131
135
|
];
|
|
132
136
|
}
|
|
133
137
|
});
|
|
138
|
+
const slug = _core.Flags.custom({
|
|
139
|
+
parse: async (str)=>{
|
|
140
|
+
const slugifiedInput = (0, _string.slugify)(str);
|
|
141
|
+
if (!slugifiedInput) {
|
|
142
|
+
throw new Error("Invalid slug provided");
|
|
143
|
+
}
|
|
144
|
+
return slugifiedInput;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const branch = slug({
|
|
148
|
+
summary: "The slug of the branch to use.",
|
|
149
|
+
// TODO Hide until branching is released in GA
|
|
150
|
+
hidden: true
|
|
151
|
+
});
|