@knocklabs/cli 0.1.9 → 0.1.11
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 +68 -531
- package/bin/dev.js +6 -0
- package/bin/run.js +7 -0
- package/dist/{commands → src/commands}/commit/get.js +24 -9
- package/dist/{commands → src/commands}/commit/index.js +23 -8
- package/dist/{commands → src/commands}/commit/list.js +29 -14
- package/dist/{commands → src/commands}/commit/promote.js +26 -11
- package/dist/{commands → src/commands}/knock.js +21 -6
- package/dist/{commands → src/commands}/layout/get.js +28 -13
- package/dist/{commands → src/commands}/layout/list.js +29 -14
- package/dist/{commands → src/commands}/layout/pull.js +47 -30
- package/dist/{commands → src/commands}/layout/push.js +38 -21
- package/dist/{commands → src/commands}/layout/validate.js +33 -16
- package/dist/src/commands/ping.js +37 -0
- package/dist/{commands → src/commands}/translation/get.js +33 -16
- package/dist/{commands → src/commands}/translation/list.js +35 -18
- package/dist/{commands → src/commands}/translation/pull.js +36 -19
- package/dist/{commands → src/commands}/translation/push.js +33 -15
- package/dist/{commands → src/commands}/translation/validate.js +30 -13
- package/dist/{commands → src/commands}/whoami.js +22 -7
- package/dist/{commands → src/commands}/workflow/activate.js +27 -12
- package/dist/{commands → src/commands}/workflow/get.js +35 -18
- package/dist/{commands → src/commands}/workflow/list.js +34 -17
- package/dist/{commands → src/commands}/workflow/new.js +37 -20
- package/dist/{commands → src/commands}/workflow/pull.js +44 -27
- package/dist/{commands → src/commands}/workflow/push.js +34 -17
- package/dist/{commands → src/commands}/workflow/run.js +25 -10
- package/dist/{commands → src/commands}/workflow/validate.js +30 -13
- package/dist/{index.js → src/index.js} +3 -1
- package/dist/{isomorphic.js → src/isomorphic.js} +8 -4
- package/dist/{lib → src/lib}/api-v1.js +57 -41
- package/dist/{lib → src/lib}/base-command.js +38 -15
- package/dist/{lib → src/lib}/helpers/const.js +18 -10
- package/dist/{lib → src/lib}/helpers/date.js +9 -5
- package/dist/{lib → src/lib}/helpers/error.js +42 -8
- package/dist/{lib → src/lib}/helpers/flag.js +24 -12
- package/dist/{lib → src/lib}/helpers/fs.js +10 -6
- package/dist/{lib → src/lib}/helpers/json.js +19 -9
- package/dist/{lib → src/lib}/helpers/liquid.js +3 -1
- package/dist/{lib → src/lib}/helpers/object.isomorphic.js +35 -7
- package/dist/{lib → src/lib}/helpers/page.js +34 -18
- package/dist/{lib → src/lib}/helpers/request.js +12 -6
- package/dist/{lib → src/lib}/helpers/string.js +8 -4
- package/dist/{lib → src/lib}/helpers/ux.js +9 -5
- package/dist/{lib → src/lib}/marshal/commit/helpers.js +3 -1
- package/dist/src/lib/marshal/commit/index.js +19 -0
- package/dist/{lib → src/lib}/marshal/conditions/helpers.js +5 -3
- package/dist/src/lib/marshal/conditions/index.js +19 -0
- package/dist/{lib → src/lib}/marshal/email-layout/helpers.js +25 -15
- package/dist/src/lib/marshal/email-layout/index.js +22 -0
- package/dist/{lib → src/lib}/marshal/email-layout/processor.isomorphic.js +17 -11
- package/dist/{lib → src/lib}/marshal/email-layout/reader.js +29 -23
- package/dist/{lib → src/lib}/marshal/email-layout/writer.js +38 -30
- package/dist/src/lib/marshal/index.isomorphic.js +26 -0
- package/dist/{lib → src/lib}/marshal/shared/const.isomorphic.js +6 -2
- package/dist/{lib → src/lib}/marshal/shared/helpers.js +22 -14
- package/dist/{lib → src/lib}/marshal/translation/helpers.js +52 -30
- package/dist/src/lib/marshal/translation/index.js +22 -0
- package/dist/src/lib/marshal/translation/processor.isomorphic.js +39 -0
- package/dist/{lib → src/lib}/marshal/translation/reader.js +14 -10
- package/dist/{lib → src/lib}/marshal/translation/writer.js +21 -15
- package/dist/{lib → src/lib}/marshal/workflow/generator.js +23 -15
- package/dist/{lib → src/lib}/marshal/workflow/helpers.js +47 -27
- package/dist/src/lib/marshal/workflow/index.js +23 -0
- package/dist/{lib → src/lib}/marshal/workflow/processor.isomorphic.js +35 -23
- package/dist/{lib → src/lib}/marshal/workflow/reader.js +30 -24
- package/dist/{lib → src/lib}/marshal/workflow/types.js +3 -1
- package/dist/{lib → src/lib}/marshal/workflow/writer.js +40 -30
- package/dist/{lib → src/lib}/run-context/helpers.js +3 -1
- package/dist/src/lib/run-context/index.js +26 -0
- package/dist/{lib → src/lib}/run-context/loader.js +17 -13
- package/dist/{lib → src/lib}/user-config.js +13 -9
- package/oclif.manifest.json +2 -1386
- package/package.json +17 -17
- package/bin/dev +0 -17
- package/bin/run +0 -5
- package/dist/commands/ping.js +0 -22
- package/dist/lib/marshal/commit/index.js +0 -17
- package/dist/lib/marshal/conditions/index.js +0 -17
- package/dist/lib/marshal/email-layout/index.js +0 -20
- package/dist/lib/marshal/index.isomorphic.js +0 -18
- package/dist/lib/marshal/translation/index.js +0 -19
- package/dist/lib/marshal/workflow/index.js +0 -21
- package/dist/lib/run-context/index.js +0 -22
- /package/dist/{lib → src/lib}/marshal/commit/types.js +0 -0
- /package/dist/{lib → src/lib}/marshal/conditions/types.js +0 -0
- /package/dist/{lib → src/lib}/marshal/email-layout/types.js +0 -0
- /package/dist/{lib → src/lib}/marshal/shared/types.js +0 -0
- /package/dist/{lib → src/lib}/marshal/translation/types.js +0 -0
- /package/dist/{lib → src/lib}/run-context/types.js +0 -0
|
@@ -4,21 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return WorkflowRun;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@oclif/core");
|
|
10
|
-
const
|
|
12
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
11
13
|
const _flag = require("../../lib/helpers/flag");
|
|
12
14
|
const _request = require("../../lib/helpers/request");
|
|
13
15
|
const _string = require("../../lib/helpers/string");
|
|
14
|
-
function
|
|
16
|
+
function _define_property(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_default(obj) {
|
|
15
30
|
return obj && obj.__esModule ? obj : {
|
|
16
31
|
default: obj
|
|
17
32
|
};
|
|
18
33
|
}
|
|
19
|
-
class WorkflowRun extends
|
|
34
|
+
class WorkflowRun extends _basecommand.default {
|
|
20
35
|
async run() {
|
|
21
|
-
const { args
|
|
36
|
+
const { args, flags } = this.props;
|
|
22
37
|
const resp = await (0, _request.withSpinner)(()=>this.apiV1.runWorkflow(this.props), {
|
|
23
38
|
action: "‣ Running"
|
|
24
39
|
});
|
|
@@ -26,8 +41,8 @@ class WorkflowRun extends _baseCommand.default {
|
|
|
26
41
|
this.log((0, _string.indentString)(`Workflow run id: ${resp.data.workflow_run_id}`, 4));
|
|
27
42
|
}
|
|
28
43
|
}
|
|
29
|
-
WorkflowRun
|
|
30
|
-
WorkflowRun
|
|
44
|
+
_define_property(WorkflowRun, "summary", "Test run a workflow using the latest version from Knock.");
|
|
45
|
+
_define_property(WorkflowRun, "flags", {
|
|
31
46
|
environment: _core.Flags.string({
|
|
32
47
|
default: "development",
|
|
33
48
|
summary: "The environment in which to run the workflow"
|
|
@@ -48,9 +63,9 @@ WorkflowRun.flags = {
|
|
|
48
63
|
data: (0, _flag.jsonStr)({
|
|
49
64
|
summary: "A JSON string of the data for this workflow"
|
|
50
65
|
})
|
|
51
|
-
};
|
|
52
|
-
WorkflowRun
|
|
66
|
+
});
|
|
67
|
+
_define_property(WorkflowRun, "args", {
|
|
53
68
|
workflowKey: _core.Args.string({
|
|
54
69
|
required: true
|
|
55
70
|
})
|
|
56
|
-
};
|
|
71
|
+
});
|
|
@@ -4,18 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return WorkflowValidate;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@oclif/core");
|
|
10
|
-
const
|
|
12
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
11
13
|
const _const = require("../../lib/helpers/const");
|
|
12
14
|
const _error = require("../../lib/helpers/error");
|
|
13
|
-
const _flag = /*#__PURE__*/
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
14
16
|
const _request = require("../../lib/helpers/request");
|
|
15
17
|
const _string = require("../../lib/helpers/string");
|
|
16
18
|
const _ux = require("../../lib/helpers/ux");
|
|
17
|
-
const _workflow = /*#__PURE__*/
|
|
18
|
-
function
|
|
19
|
+
const _workflow = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/workflow"));
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
function _interop_require_default(obj) {
|
|
19
34
|
return obj && obj.__esModule ? obj : {
|
|
20
35
|
default: obj
|
|
21
36
|
};
|
|
@@ -28,7 +43,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
28
43
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
29
44
|
})(nodeInterop);
|
|
30
45
|
}
|
|
31
|
-
function
|
|
46
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
32
47
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
33
48
|
return obj;
|
|
34
49
|
}
|
|
@@ -41,7 +56,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
41
56
|
if (cache && cache.has(obj)) {
|
|
42
57
|
return cache.get(obj);
|
|
43
58
|
}
|
|
44
|
-
var newObj = {
|
|
59
|
+
var newObj = {
|
|
60
|
+
__proto__: null
|
|
61
|
+
};
|
|
45
62
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
63
|
for(var key in obj){
|
|
47
64
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -59,7 +76,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
59
76
|
}
|
|
60
77
|
return newObj;
|
|
61
78
|
}
|
|
62
|
-
class WorkflowValidate extends
|
|
79
|
+
class WorkflowValidate extends _basecommand.default {
|
|
63
80
|
async run() {
|
|
64
81
|
// 1. Read all workflow directories found for the given command.
|
|
65
82
|
const target = await _workflow.ensureValidCommandTarget(this.props, this.runContext);
|
|
@@ -103,8 +120,8 @@ class WorkflowValidate extends _baseCommand.default {
|
|
|
103
120
|
return errors;
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
|
-
WorkflowValidate
|
|
107
|
-
WorkflowValidate
|
|
123
|
+
_define_property(WorkflowValidate, "summary", "Validate one or more workflows from a local file system.");
|
|
124
|
+
_define_property(WorkflowValidate, "flags", {
|
|
108
125
|
environment: _core.Flags.string({
|
|
109
126
|
summary: "Validating a workflow is only done in the development environment",
|
|
110
127
|
default: _const.KnockEnv.Development,
|
|
@@ -121,9 +138,9 @@ WorkflowValidate.flags = {
|
|
|
121
138
|
"all"
|
|
122
139
|
]
|
|
123
140
|
})
|
|
124
|
-
};
|
|
125
|
-
WorkflowValidate
|
|
141
|
+
});
|
|
142
|
+
_define_property(WorkflowValidate, "args", {
|
|
126
143
|
workflowKey: _core.Args.string({
|
|
127
144
|
required: false
|
|
128
145
|
})
|
|
129
|
-
};
|
|
146
|
+
});
|
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
Object.defineProperty(exports, "marshal", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: ()
|
|
9
|
+
get: function() {
|
|
10
|
+
return _indexisomorphic;
|
|
11
|
+
}
|
|
10
12
|
});
|
|
11
|
-
const
|
|
13
|
+
const _indexisomorphic = /*#__PURE__*/ _interop_require_wildcard(require("./lib/marshal/index.isomorphic"));
|
|
12
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
13
15
|
if (typeof WeakMap !== "function") return null;
|
|
14
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -17,7 +19,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
17
19
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
20
|
})(nodeInterop);
|
|
19
21
|
}
|
|
20
|
-
function
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
23
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
24
|
return obj;
|
|
23
25
|
}
|
|
@@ -30,7 +32,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
30
32
|
if (cache && cache.has(obj)) {
|
|
31
33
|
return cache.get(obj);
|
|
32
34
|
}
|
|
33
|
-
var newObj = {
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
34
38
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
39
|
for(var key in obj){
|
|
36
40
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -4,12 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ApiV1;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _axios = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
+
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
12
|
+
const _objectisomorphic = require("./helpers/object.isomorphic");
|
|
11
13
|
const _page = require("./helpers/page");
|
|
12
|
-
function
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_default(obj) {
|
|
13
28
|
return obj && obj.__esModule ? obj : {
|
|
14
29
|
default: obj
|
|
15
30
|
};
|
|
@@ -24,8 +39,8 @@ class ApiV1 {
|
|
|
24
39
|
return this.get("/whoami");
|
|
25
40
|
}
|
|
26
41
|
// By resources: Workflows
|
|
27
|
-
async listWorkflows({ flags
|
|
28
|
-
const params = (0,
|
|
42
|
+
async listWorkflows({ flags }) {
|
|
43
|
+
const params = (0, _objectisomorphic.prune)({
|
|
29
44
|
environment: flags.environment,
|
|
30
45
|
annotate: flags.annotate,
|
|
31
46
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
@@ -35,8 +50,8 @@ class ApiV1 {
|
|
|
35
50
|
params
|
|
36
51
|
});
|
|
37
52
|
}
|
|
38
|
-
async getWorkflow({ args
|
|
39
|
-
const params = (0,
|
|
53
|
+
async getWorkflow({ args, flags }) {
|
|
54
|
+
const params = (0, _objectisomorphic.prune)({
|
|
40
55
|
environment: flags.environment,
|
|
41
56
|
annotate: flags.annotate,
|
|
42
57
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
@@ -45,8 +60,8 @@ class ApiV1 {
|
|
|
45
60
|
params
|
|
46
61
|
});
|
|
47
62
|
}
|
|
48
|
-
async upsertWorkflow({ flags
|
|
49
|
-
const params = (0,
|
|
63
|
+
async upsertWorkflow({ flags }, workflow) {
|
|
64
|
+
const params = (0, _objectisomorphic.prune)({
|
|
50
65
|
environment: flags.environment,
|
|
51
66
|
annotate: flags.annotate,
|
|
52
67
|
commit: flags.commit,
|
|
@@ -59,8 +74,8 @@ class ApiV1 {
|
|
|
59
74
|
params
|
|
60
75
|
});
|
|
61
76
|
}
|
|
62
|
-
async validateWorkflow({ flags
|
|
63
|
-
const params = (0,
|
|
77
|
+
async validateWorkflow({ flags }, workflow) {
|
|
78
|
+
const params = (0, _objectisomorphic.prune)({
|
|
64
79
|
environment: flags.environment
|
|
65
80
|
});
|
|
66
81
|
const data = {
|
|
@@ -70,8 +85,8 @@ class ApiV1 {
|
|
|
70
85
|
params
|
|
71
86
|
});
|
|
72
87
|
}
|
|
73
|
-
async activateWorkflow({ args
|
|
74
|
-
const params = (0,
|
|
88
|
+
async activateWorkflow({ args, flags }) {
|
|
89
|
+
const params = (0, _objectisomorphic.prune)({
|
|
75
90
|
environment: flags.environment,
|
|
76
91
|
status: flags.status
|
|
77
92
|
});
|
|
@@ -79,11 +94,11 @@ class ApiV1 {
|
|
|
79
94
|
params
|
|
80
95
|
});
|
|
81
96
|
}
|
|
82
|
-
async runWorkflow({ args
|
|
83
|
-
const params = (0,
|
|
97
|
+
async runWorkflow({ args, flags }) {
|
|
98
|
+
const params = (0, _objectisomorphic.prune)({
|
|
84
99
|
environment: flags.environment
|
|
85
100
|
});
|
|
86
|
-
const data = (0,
|
|
101
|
+
const data = (0, _objectisomorphic.prune)({
|
|
87
102
|
recipients: flags.recipients,
|
|
88
103
|
tenant: flags.tenant,
|
|
89
104
|
data: flags.data,
|
|
@@ -94,8 +109,8 @@ class ApiV1 {
|
|
|
94
109
|
});
|
|
95
110
|
}
|
|
96
111
|
// By resources: Commits
|
|
97
|
-
async listCommits({ flags
|
|
98
|
-
const params = (0,
|
|
112
|
+
async listCommits({ flags }) {
|
|
113
|
+
const params = (0, _objectisomorphic.prune)({
|
|
99
114
|
environment: flags.environment,
|
|
100
115
|
promoted: flags.promoted,
|
|
101
116
|
...(0, _page.toPageParams)(flags)
|
|
@@ -104,11 +119,11 @@ class ApiV1 {
|
|
|
104
119
|
params
|
|
105
120
|
});
|
|
106
121
|
}
|
|
107
|
-
async getCommit({ args
|
|
122
|
+
async getCommit({ args }) {
|
|
108
123
|
return this.get(`/commits/${args.id}`);
|
|
109
124
|
}
|
|
110
|
-
async commitAllChanges({ flags
|
|
111
|
-
const params = (0,
|
|
125
|
+
async commitAllChanges({ flags }) {
|
|
126
|
+
const params = (0, _objectisomorphic.prune)({
|
|
112
127
|
environment: flags.environment,
|
|
113
128
|
commit_message: flags["commit-message"]
|
|
114
129
|
});
|
|
@@ -116,20 +131,20 @@ class ApiV1 {
|
|
|
116
131
|
params
|
|
117
132
|
});
|
|
118
133
|
}
|
|
119
|
-
async promoteAllChanges({ flags
|
|
120
|
-
const params = (0,
|
|
134
|
+
async promoteAllChanges({ flags }) {
|
|
135
|
+
const params = (0, _objectisomorphic.prune)({
|
|
121
136
|
to_environment: flags.to
|
|
122
137
|
});
|
|
123
138
|
return this.put(`/commits/promote`, {}, {
|
|
124
139
|
params
|
|
125
140
|
});
|
|
126
141
|
}
|
|
127
|
-
async promoteOneChange({ flags
|
|
142
|
+
async promoteOneChange({ flags }) {
|
|
128
143
|
return this.put(`/commits/${flags.only}/promote`);
|
|
129
144
|
}
|
|
130
145
|
// By resources: Translations
|
|
131
|
-
async listTranslations({ flags
|
|
132
|
-
const params = (0,
|
|
146
|
+
async listTranslations({ flags }, filters = {}) {
|
|
147
|
+
const params = (0, _objectisomorphic.prune)({
|
|
133
148
|
environment: flags.environment,
|
|
134
149
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
135
150
|
locale_code: filters.localeCode,
|
|
@@ -140,8 +155,8 @@ class ApiV1 {
|
|
|
140
155
|
params
|
|
141
156
|
});
|
|
142
157
|
}
|
|
143
|
-
async getTranslation({ flags
|
|
144
|
-
const params = (0,
|
|
158
|
+
async getTranslation({ flags }, translation) {
|
|
159
|
+
const params = (0, _objectisomorphic.prune)({
|
|
145
160
|
environment: flags.environment,
|
|
146
161
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
147
162
|
namespace: translation.namespace
|
|
@@ -150,8 +165,8 @@ class ApiV1 {
|
|
|
150
165
|
params
|
|
151
166
|
});
|
|
152
167
|
}
|
|
153
|
-
async upsertTranslation({ flags
|
|
154
|
-
const params = (0,
|
|
168
|
+
async upsertTranslation({ flags }, translation) {
|
|
169
|
+
const params = (0, _objectisomorphic.prune)({
|
|
155
170
|
environment: flags.environment,
|
|
156
171
|
commit: flags.commit,
|
|
157
172
|
commit_message: flags["commit-message"],
|
|
@@ -163,8 +178,8 @@ class ApiV1 {
|
|
|
163
178
|
params
|
|
164
179
|
});
|
|
165
180
|
}
|
|
166
|
-
async validateTranslation({ flags
|
|
167
|
-
const params = (0,
|
|
181
|
+
async validateTranslation({ flags }, translation) {
|
|
182
|
+
const params = (0, _objectisomorphic.prune)({
|
|
168
183
|
environment: flags.environment,
|
|
169
184
|
namespace: translation.namespace
|
|
170
185
|
});
|
|
@@ -176,8 +191,8 @@ class ApiV1 {
|
|
|
176
191
|
});
|
|
177
192
|
}
|
|
178
193
|
// By resources: Email layouts
|
|
179
|
-
async listEmailLayouts({ flags
|
|
180
|
-
const params = (0,
|
|
194
|
+
async listEmailLayouts({ flags }) {
|
|
195
|
+
const params = (0, _objectisomorphic.prune)({
|
|
181
196
|
environment: flags.environment,
|
|
182
197
|
annotate: flags.annotate,
|
|
183
198
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
@@ -187,8 +202,8 @@ class ApiV1 {
|
|
|
187
202
|
params
|
|
188
203
|
});
|
|
189
204
|
}
|
|
190
|
-
async getEmailLayout({ args
|
|
191
|
-
const params = (0,
|
|
205
|
+
async getEmailLayout({ args, flags }) {
|
|
206
|
+
const params = (0, _objectisomorphic.prune)({
|
|
192
207
|
environment: flags.environment,
|
|
193
208
|
annotate: flags.annotate,
|
|
194
209
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
@@ -197,8 +212,8 @@ class ApiV1 {
|
|
|
197
212
|
params
|
|
198
213
|
});
|
|
199
214
|
}
|
|
200
|
-
async upsertEmailLayout({ flags
|
|
201
|
-
const params = (0,
|
|
215
|
+
async upsertEmailLayout({ flags }, layout) {
|
|
216
|
+
const params = (0, _objectisomorphic.prune)({
|
|
202
217
|
environment: flags.environment,
|
|
203
218
|
annotate: flags.annotate,
|
|
204
219
|
commit: flags.commit,
|
|
@@ -211,8 +226,8 @@ class ApiV1 {
|
|
|
211
226
|
params
|
|
212
227
|
});
|
|
213
228
|
}
|
|
214
|
-
async validateEmailLayout({ flags
|
|
215
|
-
const params = (0,
|
|
229
|
+
async validateEmailLayout({ flags }, layout) {
|
|
230
|
+
const params = (0, _objectisomorphic.prune)({
|
|
216
231
|
environment: flags.environment
|
|
217
232
|
});
|
|
218
233
|
const data = {
|
|
@@ -230,6 +245,7 @@ class ApiV1 {
|
|
|
230
245
|
return this.client.put(`/${API_VERSION}` + subpath, data, config);
|
|
231
246
|
}
|
|
232
247
|
constructor(flags, config){
|
|
248
|
+
_define_property(this, "client", void 0);
|
|
233
249
|
const baseURL = flags["api-origin"] || DEFAULT_ORIGIN;
|
|
234
250
|
this.client = _axios.default.create({
|
|
235
251
|
baseURL,
|
|
@@ -4,13 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@oclif/core");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
function
|
|
12
|
+
const _apiv1 = /*#__PURE__*/ _interop_require_default(require("./api-v1"));
|
|
13
|
+
const _runcontext = /*#__PURE__*/ _interop_require_wildcard(require("./run-context"));
|
|
14
|
+
const _userconfig = /*#__PURE__*/ _interop_require_default(require("./user-config"));
|
|
15
|
+
function _define_property(obj, key, value) {
|
|
16
|
+
if (key in obj) {
|
|
17
|
+
Object.defineProperty(obj, key, {
|
|
18
|
+
value: value,
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
obj[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_default(obj) {
|
|
14
29
|
return obj && obj.__esModule ? obj : {
|
|
15
30
|
default: obj
|
|
16
31
|
};
|
|
@@ -23,7 +38,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
23
38
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
24
39
|
})(nodeInterop);
|
|
25
40
|
}
|
|
26
|
-
function
|
|
41
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
27
42
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
28
43
|
return obj;
|
|
29
44
|
}
|
|
@@ -36,7 +51,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
36
51
|
if (cache && cache.has(obj)) {
|
|
37
52
|
return cache.get(obj);
|
|
38
53
|
}
|
|
39
|
-
var newObj = {
|
|
54
|
+
var newObj = {
|
|
55
|
+
__proto__: null
|
|
56
|
+
};
|
|
40
57
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
58
|
for(var key in obj){
|
|
42
59
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -58,21 +75,27 @@ class BaseCommand extends _core.Command {
|
|
|
58
75
|
async init() {
|
|
59
76
|
await super.init();
|
|
60
77
|
// 1. Load user's config from the config dir, as available.
|
|
61
|
-
await
|
|
78
|
+
await _userconfig.default.load(this.config.configDir);
|
|
62
79
|
// 2. Parse flags and args, must come after the user config load.
|
|
63
|
-
const { args
|
|
80
|
+
const { args, flags } = await this.parse(this.ctor);
|
|
64
81
|
this.props = {
|
|
65
82
|
args: args,
|
|
66
83
|
flags: flags
|
|
67
84
|
};
|
|
68
85
|
// 3. Instantiate a knock api client.
|
|
69
|
-
this.apiV1 = new
|
|
86
|
+
this.apiV1 = new _apiv1.default(this.props.flags, this.config);
|
|
70
87
|
// 4. Load the run context of the invoked command.
|
|
71
|
-
this.runContext = await
|
|
88
|
+
this.runContext = await _runcontext.load(this.id);
|
|
89
|
+
}
|
|
90
|
+
constructor(...args){
|
|
91
|
+
super(...args);
|
|
92
|
+
_define_property(this, "props", void 0);
|
|
93
|
+
_define_property(this, "apiV1", void 0);
|
|
94
|
+
_define_property(this, "runContext", void 0);
|
|
72
95
|
}
|
|
73
96
|
}
|
|
74
97
|
// Base flags are inherited by any command that extends BaseCommand.
|
|
75
|
-
BaseCommand
|
|
98
|
+
_define_property(BaseCommand, "baseFlags", {
|
|
76
99
|
// Evaluated in the following precedence:
|
|
77
100
|
// - service token flag passed into the command
|
|
78
101
|
// - if not provided, fall back to env variable
|
|
@@ -82,14 +105,14 @@ BaseCommand.baseFlags = {
|
|
|
82
105
|
required: true,
|
|
83
106
|
multiple: false,
|
|
84
107
|
env: "KNOCK_SERVICE_TOKEN",
|
|
85
|
-
default: async ()=>
|
|
108
|
+
default: async ()=>_userconfig.default.get().serviceToken
|
|
86
109
|
}),
|
|
87
110
|
// Hidden flag to use a different api base url for development purposes.
|
|
88
111
|
"api-origin": _core.Flags.string({
|
|
89
112
|
hidden: true,
|
|
90
113
|
required: false,
|
|
91
114
|
multiple: false,
|
|
92
|
-
default: async ()=>
|
|
115
|
+
default: async ()=>_userconfig.default.get().apiOrigin
|
|
93
116
|
})
|
|
94
|
-
};
|
|
117
|
+
});
|
|
95
118
|
const _default = BaseCommand;
|
|
@@ -9,14 +9,20 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
KnockEnv: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
KnockEnv: function() {
|
|
13
|
+
return KnockEnv;
|
|
14
|
+
},
|
|
15
|
+
isTestEnv: function() {
|
|
16
|
+
return isTestEnv;
|
|
17
|
+
},
|
|
18
|
+
sandboxDir: function() {
|
|
19
|
+
return sandboxDir;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
function
|
|
22
|
+
const _nodeos = /*#__PURE__*/ _interop_require_default(require("node:os"));
|
|
23
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
24
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
25
|
+
function _interop_require_default(obj) {
|
|
20
26
|
return obj && obj.__esModule ? obj : {
|
|
21
27
|
default: obj
|
|
22
28
|
};
|
|
@@ -29,7 +35,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
29
35
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
30
36
|
})(nodeInterop);
|
|
31
37
|
}
|
|
32
|
-
function
|
|
38
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
33
39
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
34
40
|
return obj;
|
|
35
41
|
}
|
|
@@ -42,7 +48,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
42
48
|
if (cache && cache.has(obj)) {
|
|
43
49
|
return cache.get(obj);
|
|
44
50
|
}
|
|
45
|
-
var newObj = {
|
|
51
|
+
var newObj = {
|
|
52
|
+
__proto__: null
|
|
53
|
+
};
|
|
46
54
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
47
55
|
for(var key in obj){
|
|
48
56
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -66,4 +74,4 @@ var KnockEnv;
|
|
|
66
74
|
KnockEnv["Production"] = "production";
|
|
67
75
|
})(KnockEnv || (KnockEnv = {}));
|
|
68
76
|
const isTestEnv = process.env.NODE_ENV === "test";
|
|
69
|
-
const sandboxDir =
|
|
77
|
+
const sandboxDir = _nodepath.resolve(_fsextra.realpathSync(_nodeos.default.tmpdir()), ".knock");
|
|
@@ -9,13 +9,17 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
formatDate: ()
|
|
13
|
-
|
|
12
|
+
formatDate: function() {
|
|
13
|
+
return formatDate;
|
|
14
|
+
},
|
|
15
|
+
formatDateTime: function() {
|
|
16
|
+
return formatDateTime;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const
|
|
19
|
+
const _datefns = require("date-fns");
|
|
16
20
|
function formatDate(input) {
|
|
17
|
-
return (0,
|
|
21
|
+
return (0, _datefns.format)((0, _datefns.parseISO)(input), "MMM d, yyyy");
|
|
18
22
|
}
|
|
19
23
|
function formatDateTime(input) {
|
|
20
|
-
return (0,
|
|
24
|
+
return (0, _datefns.format)((0, _datefns.parseISO)(input), "MMM d, yyyy HH:mm:ss");
|
|
21
25
|
}
|