@knocklabs/cli 0.1.10 → 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 +34 -17
- 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/{lib → src/lib}/marshal/translation/processor.isomorphic.js +9 -3
- 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 +15 -15
- 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 -20
- package/dist/lib/marshal/translation/index.js +0 -20
- 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,20 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailLayoutPull;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
11
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
10
12
|
const _core = require("@oclif/core");
|
|
11
|
-
const
|
|
13
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
12
14
|
const _error = require("../../lib/helpers/error");
|
|
13
|
-
const _flag = /*#__PURE__*/
|
|
14
|
-
const
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
16
|
+
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
15
17
|
const _page = require("../../lib/helpers/page");
|
|
16
18
|
const _request = require("../../lib/helpers/request");
|
|
17
19
|
const _ux = require("../../lib/helpers/ux");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
function
|
|
20
|
+
const _emaillayout = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/email-layout"));
|
|
21
|
+
const _runcontext = require("../../lib/run-context");
|
|
22
|
+
function _define_property(obj, key, value) {
|
|
23
|
+
if (key in obj) {
|
|
24
|
+
Object.defineProperty(obj, key, {
|
|
25
|
+
value: value,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
obj[key] = value;
|
|
32
|
+
}
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
function _interop_require_default(obj) {
|
|
21
36
|
return obj && obj.__esModule ? obj : {
|
|
22
37
|
default: obj
|
|
23
38
|
};
|
|
@@ -30,7 +45,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
30
45
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
46
|
})(nodeInterop);
|
|
32
47
|
}
|
|
33
|
-
function
|
|
48
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
49
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
50
|
return obj;
|
|
36
51
|
}
|
|
@@ -43,7 +58,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
43
58
|
if (cache && cache.has(obj)) {
|
|
44
59
|
return cache.get(obj);
|
|
45
60
|
}
|
|
46
|
-
var newObj = {
|
|
61
|
+
var newObj = {
|
|
62
|
+
__proto__: null
|
|
63
|
+
};
|
|
47
64
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
65
|
for(var key in obj){
|
|
49
66
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -61,9 +78,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
61
78
|
}
|
|
62
79
|
return newObj;
|
|
63
80
|
}
|
|
64
|
-
class EmailLayoutPull extends
|
|
81
|
+
class EmailLayoutPull extends _basecommand.default {
|
|
65
82
|
async run() {
|
|
66
|
-
const { args
|
|
83
|
+
const { args, flags } = this.props;
|
|
67
84
|
if (flags.all && args.emailLayoutKey) {
|
|
68
85
|
return this.error(`emailLayoutKey arg \`${args.emailLayoutKey}\` cannot also be provided when using --all`);
|
|
69
86
|
}
|
|
@@ -71,7 +88,7 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
71
88
|
}
|
|
72
89
|
// Pull one email layout
|
|
73
90
|
async pullOneEmailLayout() {
|
|
74
|
-
const { flags
|
|
91
|
+
const { flags } = this.props;
|
|
75
92
|
const dirContext = await this.getEmailLayoutDirContext();
|
|
76
93
|
if (dirContext.exists) {
|
|
77
94
|
this.log(`‣ Found \`${dirContext.key}\` at ${dirContext.abspath}`);
|
|
@@ -81,7 +98,7 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
81
98
|
if (!input) return;
|
|
82
99
|
}
|
|
83
100
|
const resp = await (0, _request.withSpinner)(()=>{
|
|
84
|
-
const props = (0,
|
|
101
|
+
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
85
102
|
args: {
|
|
86
103
|
emailLayoutKey: dirContext.key
|
|
87
104
|
},
|
|
@@ -91,13 +108,13 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
91
108
|
});
|
|
92
109
|
return this.apiV1.getEmailLayout(props);
|
|
93
110
|
});
|
|
94
|
-
await
|
|
111
|
+
await _emaillayout.writeEmailLayoutDirFromData(dirContext, resp.data);
|
|
95
112
|
const action = dirContext.exists ? "updated" : "created";
|
|
96
113
|
this.log(`‣ Successfully ${action} \`${dirContext.key}\` at ${dirContext.abspath}`);
|
|
97
114
|
}
|
|
98
115
|
// Pull all email layouts
|
|
99
116
|
async pullAllEmailLayouts() {
|
|
100
|
-
const { flags
|
|
117
|
+
const { flags } = this.props;
|
|
101
118
|
const defaultToCwd = {
|
|
102
119
|
abspath: this.runContext.cwd,
|
|
103
120
|
exists: true
|
|
@@ -108,13 +125,13 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
108
125
|
if (!input) return;
|
|
109
126
|
_ux.spinner.start(`‣ Loading`);
|
|
110
127
|
const emailLayouts = await this.listAllEmailLayouts();
|
|
111
|
-
await
|
|
128
|
+
await _emaillayout.writeEmailLayoutIndexDir(targetDirCtx, emailLayouts);
|
|
112
129
|
_ux.spinner.stop();
|
|
113
130
|
const action = targetDirCtx.exists ? "updated" : "created";
|
|
114
131
|
this.log(`‣ Successfully ${action} the layouts directory at ${targetDirCtx.abspath}`);
|
|
115
132
|
}
|
|
116
133
|
async listAllEmailLayouts(pageParams = {}, emailLayoutsFetchedSoFar = []) {
|
|
117
|
-
const props = (0,
|
|
134
|
+
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
118
135
|
flags: {
|
|
119
136
|
...pageParams,
|
|
120
137
|
annotate: true,
|
|
@@ -126,7 +143,7 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
126
143
|
const message = (0, _request.formatErrorRespMessage)(resp);
|
|
127
144
|
this.error(new _error.ApiError(message));
|
|
128
145
|
}
|
|
129
|
-
const { entries
|
|
146
|
+
const { entries, page_info: pageInfo } = resp.data;
|
|
130
147
|
const emailLayouts = [
|
|
131
148
|
...emailLayoutsFetchedSoFar,
|
|
132
149
|
...entries
|
|
@@ -136,22 +153,22 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
136
153
|
}, emailLayouts) : emailLayouts;
|
|
137
154
|
}
|
|
138
155
|
async getEmailLayoutDirContext() {
|
|
139
|
-
const { emailLayoutKey
|
|
140
|
-
const { resourceDir
|
|
156
|
+
const { emailLayoutKey } = this.props.args;
|
|
157
|
+
const { resourceDir, cwd: runCwd } = this.runContext;
|
|
141
158
|
// Inside an existing resource dir, use it if valid for the target email layout.
|
|
142
159
|
if (resourceDir) {
|
|
143
160
|
const target = {
|
|
144
|
-
commandId:
|
|
161
|
+
commandId: _basecommand.default.id,
|
|
145
162
|
type: "email_layout",
|
|
146
163
|
key: emailLayoutKey
|
|
147
164
|
};
|
|
148
|
-
return (0,
|
|
165
|
+
return (0, _runcontext.ensureResourceDirForTarget)(resourceDir, target);
|
|
149
166
|
}
|
|
150
167
|
// Not inside any existing email layout directory, which means either create a
|
|
151
168
|
// new email layout directory in the cwd, or update it if there is one already.
|
|
152
169
|
if (emailLayoutKey) {
|
|
153
|
-
const dirPath =
|
|
154
|
-
const exists = await
|
|
170
|
+
const dirPath = _nodepath.resolve(runCwd, emailLayoutKey);
|
|
171
|
+
const exists = await _emaillayout.isEmailLayoutDir(dirPath);
|
|
155
172
|
return {
|
|
156
173
|
type: "email_layout",
|
|
157
174
|
key: emailLayoutKey,
|
|
@@ -163,8 +180,8 @@ class EmailLayoutPull extends _baseCommand.default {
|
|
|
163
180
|
return this.error("Missing 1 required arg:\nemailLayoutKey");
|
|
164
181
|
}
|
|
165
182
|
}
|
|
166
|
-
EmailLayoutPull
|
|
167
|
-
EmailLayoutPull
|
|
183
|
+
_define_property(EmailLayoutPull, "summary", "Pull one or more email layouts from an environment into a local file system.");
|
|
184
|
+
_define_property(EmailLayoutPull, "flags", {
|
|
168
185
|
environment: _core.Flags.string({
|
|
169
186
|
default: "development",
|
|
170
187
|
summary: "The environment to use."
|
|
@@ -187,9 +204,9 @@ EmailLayoutPull.flags = {
|
|
|
187
204
|
force: _core.Flags.boolean({
|
|
188
205
|
summary: "Remove the confirmation prompt."
|
|
189
206
|
})
|
|
190
|
-
};
|
|
191
|
-
EmailLayoutPull
|
|
207
|
+
});
|
|
208
|
+
_define_property(EmailLayoutPull, "args", {
|
|
192
209
|
emailLayoutKey: _core.Args.string({
|
|
193
210
|
required: false
|
|
194
211
|
})
|
|
195
|
-
};
|
|
212
|
+
});
|
|
@@ -4,20 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailLayoutPush;
|
|
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__*/
|
|
14
|
-
const
|
|
15
|
+
const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
|
|
16
|
+
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
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
|
-
const
|
|
19
|
-
const _validate = /*#__PURE__*/
|
|
20
|
-
function
|
|
20
|
+
const _emaillayout = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/email-layout"));
|
|
21
|
+
const _validate = /*#__PURE__*/ _interop_require_default(require("./validate"));
|
|
22
|
+
function _define_property(obj, key, value) {
|
|
23
|
+
if (key in obj) {
|
|
24
|
+
Object.defineProperty(obj, key, {
|
|
25
|
+
value: value,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
obj[key] = value;
|
|
32
|
+
}
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
function _interop_require_default(obj) {
|
|
21
36
|
return obj && obj.__esModule ? obj : {
|
|
22
37
|
default: obj
|
|
23
38
|
};
|
|
@@ -30,7 +45,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
30
45
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
46
|
})(nodeInterop);
|
|
32
47
|
}
|
|
33
|
-
function
|
|
48
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
49
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
50
|
return obj;
|
|
36
51
|
}
|
|
@@ -43,7 +58,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
43
58
|
if (cache && cache.has(obj)) {
|
|
44
59
|
return cache.get(obj);
|
|
45
60
|
}
|
|
46
|
-
var newObj = {
|
|
61
|
+
var newObj = {
|
|
62
|
+
__proto__: null
|
|
63
|
+
};
|
|
47
64
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
65
|
for(var key in obj){
|
|
49
66
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -61,12 +78,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
61
78
|
}
|
|
62
79
|
return newObj;
|
|
63
80
|
}
|
|
64
|
-
class EmailLayoutPush extends
|
|
81
|
+
class EmailLayoutPush extends _basecommand.default {
|
|
65
82
|
async run() {
|
|
66
|
-
const { flags
|
|
83
|
+
const { flags } = this.props;
|
|
67
84
|
// 1. First read all layout directories found for the given command.
|
|
68
|
-
const target = await
|
|
69
|
-
const [layouts, readErrors] = await
|
|
85
|
+
const target = await _emaillayout.ensureValidCommandTarget(this.props, this.runContext);
|
|
86
|
+
const [layouts, readErrors] = await _emaillayout.readAllForCommandTarget(target, {
|
|
70
87
|
withExtractedFiles: true
|
|
71
88
|
});
|
|
72
89
|
if (readErrors.length > 0) {
|
|
@@ -89,7 +106,7 @@ class EmailLayoutPush extends _baseCommand.default {
|
|
|
89
106
|
// 3. Finally push up each layout, abort on the first error.
|
|
90
107
|
_ux.spinner.start(`‣ Pushing`);
|
|
91
108
|
for (const layout of layouts){
|
|
92
|
-
const props = (0,
|
|
109
|
+
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
93
110
|
flags: {
|
|
94
111
|
annotate: true
|
|
95
112
|
}
|
|
@@ -103,10 +120,10 @@ class EmailLayoutPush extends _baseCommand.default {
|
|
|
103
120
|
// Update the layout directory with the successfully pushed layout
|
|
104
121
|
// payload from the server.
|
|
105
122
|
// eslint-disable-next-line no-await-in-loop
|
|
106
|
-
await
|
|
123
|
+
await _emaillayout.writeEmailLayoutDirFromData(layout, resp.data.email_layout);
|
|
107
124
|
continue;
|
|
108
125
|
}
|
|
109
|
-
const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp),
|
|
126
|
+
const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _emaillayout.emailLayoutJsonPath(layout), "ApiError");
|
|
110
127
|
this.error((0, _error.formatError)(error));
|
|
111
128
|
}
|
|
112
129
|
_ux.spinner.stop();
|
|
@@ -116,8 +133,8 @@ class EmailLayoutPush extends _baseCommand.default {
|
|
|
116
133
|
this.log(`‣ Successfully ${actioned} ${layouts.length} layout(s):\n` + (0, _string.indentString)(layoutKeys.join("\n"), 4));
|
|
117
134
|
}
|
|
118
135
|
}
|
|
119
|
-
EmailLayoutPush
|
|
120
|
-
EmailLayoutPush
|
|
136
|
+
_define_property(EmailLayoutPush, "summary", "Push one or more email layouts from a local file system to Knock.");
|
|
137
|
+
_define_property(EmailLayoutPush, "flags", {
|
|
121
138
|
environment: _core.Flags.string({
|
|
122
139
|
summary: "Pushing an email layout is only allowed in the development environment",
|
|
123
140
|
default: _const.KnockEnv.Development,
|
|
@@ -147,9 +164,9 @@ EmailLayoutPush.flags = {
|
|
|
147
164
|
"commit"
|
|
148
165
|
]
|
|
149
166
|
})
|
|
150
|
-
};
|
|
151
|
-
EmailLayoutPush
|
|
167
|
+
});
|
|
168
|
+
_define_property(EmailLayoutPush, "args", {
|
|
152
169
|
emailLayoutKey: _core.Args.string({
|
|
153
170
|
required: false
|
|
154
171
|
})
|
|
155
|
-
};
|
|
172
|
+
});
|
|
@@ -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 EmailLayoutValidate;
|
|
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
|
|
18
|
-
function
|
|
19
|
+
const _emaillayout = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/email-layout"));
|
|
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,11 +76,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
59
76
|
}
|
|
60
77
|
return newObj;
|
|
61
78
|
}
|
|
62
|
-
class EmailLayoutValidate extends
|
|
79
|
+
class EmailLayoutValidate extends _basecommand.default {
|
|
63
80
|
async run() {
|
|
64
81
|
// 1. Read all layout directories found for the given command.
|
|
65
|
-
const target = await
|
|
66
|
-
const [layouts, readErrors] = await
|
|
82
|
+
const target = await _emaillayout.ensureValidCommandTarget(this.props, this.runContext);
|
|
83
|
+
const [layouts, readErrors] = await _emaillayout.readAllForCommandTarget(target, {
|
|
67
84
|
withExtractedFiles: true
|
|
68
85
|
});
|
|
69
86
|
if (readErrors.length > 0) {
|
|
@@ -94,15 +111,15 @@ class EmailLayoutValidate extends _baseCommand.default {
|
|
|
94
111
|
key: layout.key
|
|
95
112
|
});
|
|
96
113
|
if ((0, _request.isSuccessResp)(resp)) return;
|
|
97
|
-
const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp),
|
|
114
|
+
const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _emaillayout.emailLayoutJsonPath(layout), "ApiError");
|
|
98
115
|
return error;
|
|
99
116
|
});
|
|
100
117
|
const errors = (await Promise.all(errorPromises)).filter((e)=>Boolean(e));
|
|
101
118
|
return errors;
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
|
-
EmailLayoutValidate
|
|
105
|
-
EmailLayoutValidate
|
|
121
|
+
_define_property(EmailLayoutValidate, "summary", "Validate one or more layouts from a local file system.");
|
|
122
|
+
_define_property(EmailLayoutValidate, "flags", {
|
|
106
123
|
environment: _core.Flags.string({
|
|
107
124
|
summary: "Validating a layout is only done in the development environment",
|
|
108
125
|
default: _const.KnockEnv.Development,
|
|
@@ -122,9 +139,9 @@ EmailLayoutValidate.flags = {
|
|
|
122
139
|
"email-layouts-dir"
|
|
123
140
|
]
|
|
124
141
|
})
|
|
125
|
-
};
|
|
126
|
-
EmailLayoutValidate
|
|
142
|
+
});
|
|
143
|
+
_define_property(EmailLayoutValidate, "args", {
|
|
127
144
|
emailLayoutKey: _core.Args.string({
|
|
128
145
|
required: false
|
|
129
146
|
})
|
|
130
|
-
};
|
|
147
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Ping;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../lib/base-command"));
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_default(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
class Ping extends _basecommand.default {
|
|
31
|
+
async run() {
|
|
32
|
+
const resp = await this.apiV1.ping();
|
|
33
|
+
this.log(resp.data);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Deprecated, in favor of the whoami command.
|
|
37
|
+
_define_property(Ping, "hidden", true);
|
|
@@ -4,14 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TranslationGet;
|
|
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 _date = require("../../lib/helpers/date");
|
|
12
14
|
const _request = require("../../lib/helpers/request");
|
|
13
|
-
const _translation = /*#__PURE__*/
|
|
14
|
-
function
|
|
15
|
+
const _translation = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/translation"));
|
|
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
|
};
|
|
@@ -24,7 +39,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
24
39
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
40
|
})(nodeInterop);
|
|
26
41
|
}
|
|
27
|
-
function
|
|
42
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
43
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
44
|
return obj;
|
|
30
45
|
}
|
|
@@ -37,7 +52,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
37
52
|
if (cache && cache.has(obj)) {
|
|
38
53
|
return cache.get(obj);
|
|
39
54
|
}
|
|
40
|
-
var newObj = {
|
|
55
|
+
var newObj = {
|
|
56
|
+
__proto__: null
|
|
57
|
+
};
|
|
41
58
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
59
|
for(var key in obj){
|
|
43
60
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -55,9 +72,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
55
72
|
}
|
|
56
73
|
return newObj;
|
|
57
74
|
}
|
|
58
|
-
class TranslationGet extends
|
|
75
|
+
class TranslationGet extends _basecommand.default {
|
|
59
76
|
async run() {
|
|
60
|
-
const { args
|
|
77
|
+
const { args, flags } = this.props;
|
|
61
78
|
const parsedRef = _translation.parseTranslationRef(args.translationRef);
|
|
62
79
|
if (!parsedRef) {
|
|
63
80
|
return this.error(`Invalid translation ref \`${args.translationRef}\`, use valid <locale> or <namespace>.<locale> for namespaced translations`);
|
|
@@ -67,8 +84,8 @@ class TranslationGet extends _baseCommand.default {
|
|
|
67
84
|
this.render(resp.data);
|
|
68
85
|
}
|
|
69
86
|
render(translation) {
|
|
70
|
-
const { translationRef
|
|
71
|
-
const { environment: env
|
|
87
|
+
const { translationRef } = this.props.args;
|
|
88
|
+
const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
72
89
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
73
90
|
this.log(`‣ Showing translation \`${translationRef}\` in \`${env}\` environment ${qualifier}\n`);
|
|
74
91
|
/*
|
|
@@ -109,8 +126,8 @@ class TranslationGet extends _baseCommand.default {
|
|
|
109
126
|
_core.ux.styledJSON(JSON.parse(translation.content));
|
|
110
127
|
}
|
|
111
128
|
}
|
|
112
|
-
TranslationGet
|
|
113
|
-
TranslationGet
|
|
129
|
+
_define_property(TranslationGet, "summary", "Display a single translation from an environment.");
|
|
130
|
+
_define_property(TranslationGet, "flags", {
|
|
114
131
|
environment: _core.Flags.string({
|
|
115
132
|
default: "development",
|
|
116
133
|
summary: "The environment to use."
|
|
@@ -118,11 +135,11 @@ TranslationGet.flags = {
|
|
|
118
135
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
119
136
|
summary: "Hide any uncommitted changes."
|
|
120
137
|
})
|
|
121
|
-
};
|
|
122
|
-
TranslationGet
|
|
138
|
+
});
|
|
139
|
+
_define_property(TranslationGet, "args", {
|
|
123
140
|
translationRef: _core.Args.string({
|
|
124
141
|
description: _translation.translationRefDescription,
|
|
125
142
|
required: true
|
|
126
143
|
})
|
|
127
|
-
};
|
|
128
|
-
TranslationGet
|
|
144
|
+
});
|
|
145
|
+
_define_property(TranslationGet, "enableJsonFlag", true);
|
|
@@ -4,16 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TranslationList;
|
|
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 _date = require("../../lib/helpers/date");
|
|
12
|
-
const
|
|
14
|
+
const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
|
|
13
15
|
const _page = require("../../lib/helpers/page");
|
|
14
16
|
const _request = require("../../lib/helpers/request");
|
|
15
|
-
const _translation = /*#__PURE__*/
|
|
16
|
-
function
|
|
17
|
+
const _translation = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/translation"));
|
|
18
|
+
function _define_property(obj, key, value) {
|
|
19
|
+
if (key in obj) {
|
|
20
|
+
Object.defineProperty(obj, key, {
|
|
21
|
+
value: value,
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
obj[key] = value;
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function _interop_require_default(obj) {
|
|
17
32
|
return obj && obj.__esModule ? obj : {
|
|
18
33
|
default: obj
|
|
19
34
|
};
|
|
@@ -26,7 +41,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
26
41
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
42
|
})(nodeInterop);
|
|
28
43
|
}
|
|
29
|
-
function
|
|
44
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
45
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
46
|
return obj;
|
|
32
47
|
}
|
|
@@ -39,7 +54,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
39
54
|
if (cache && cache.has(obj)) {
|
|
40
55
|
return cache.get(obj);
|
|
41
56
|
}
|
|
42
|
-
var newObj = {
|
|
57
|
+
var newObj = {
|
|
58
|
+
__proto__: null
|
|
59
|
+
};
|
|
43
60
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
61
|
for(var key in obj){
|
|
45
62
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -57,15 +74,15 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
57
74
|
}
|
|
58
75
|
return newObj;
|
|
59
76
|
}
|
|
60
|
-
class TranslationList extends
|
|
77
|
+
class TranslationList extends _basecommand.default {
|
|
61
78
|
async run() {
|
|
62
79
|
const resp = await this.request();
|
|
63
|
-
const { flags
|
|
80
|
+
const { flags } = this.props;
|
|
64
81
|
if (flags.json) return resp.data;
|
|
65
82
|
this.render(resp.data);
|
|
66
83
|
}
|
|
67
84
|
async request(pageParams = {}) {
|
|
68
|
-
const props = (0,
|
|
85
|
+
const props = (0, _objectisomorphic.merge)(this.props, {
|
|
69
86
|
flags: {
|
|
70
87
|
...pageParams
|
|
71
88
|
}
|
|
@@ -73,8 +90,8 @@ class TranslationList extends _baseCommand.default {
|
|
|
73
90
|
return (0, _request.withSpinner)(()=>this.apiV1.listTranslations(props));
|
|
74
91
|
}
|
|
75
92
|
async render(data) {
|
|
76
|
-
const { entries
|
|
77
|
-
const { environment: env
|
|
93
|
+
const { entries } = data;
|
|
94
|
+
const { environment: env, "hide-uncommitted-changes": committedOnly } = this.props.flags;
|
|
78
95
|
const qualifier = env === "development" && !committedOnly ? "(including uncommitted)" : "";
|
|
79
96
|
this.log(`‣ Showing ${entries.length} translations in \`${env}\` environment ${qualifier}\n`);
|
|
80
97
|
/*
|
|
@@ -106,7 +123,7 @@ class TranslationList extends _baseCommand.default {
|
|
|
106
123
|
return this.prompt(data);
|
|
107
124
|
}
|
|
108
125
|
async prompt(data) {
|
|
109
|
-
const { page_info
|
|
126
|
+
const { page_info } = data;
|
|
110
127
|
const pageAction = await (0, _page.maybePromptPageAction)(page_info);
|
|
111
128
|
const pageParams = pageAction && (0, _page.paramsForPageAction)(pageAction, page_info);
|
|
112
129
|
if (pageParams) {
|
|
@@ -116,8 +133,8 @@ class TranslationList extends _baseCommand.default {
|
|
|
116
133
|
}
|
|
117
134
|
}
|
|
118
135
|
}
|
|
119
|
-
TranslationList
|
|
120
|
-
TranslationList
|
|
136
|
+
_define_property(TranslationList, "summary", "Display all translations for an environment.");
|
|
137
|
+
_define_property(TranslationList, "flags", {
|
|
121
138
|
environment: _core.Flags.string({
|
|
122
139
|
default: "development",
|
|
123
140
|
summary: "The environment to use."
|
|
@@ -126,5 +143,5 @@ TranslationList.flags = {
|
|
|
126
143
|
summary: "Hide any uncommitted changes."
|
|
127
144
|
}),
|
|
128
145
|
..._page.pageFlags
|
|
129
|
-
};
|
|
130
|
-
TranslationList
|
|
146
|
+
});
|
|
147
|
+
_define_property(TranslationList, "enableJsonFlag", true);
|