@knocklabs/cli 0.1.4 → 0.1.6

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.
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>EmailLayoutPush
8
+ });
9
+ const _core = require("@oclif/core");
10
+ const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
11
+ const _const = require("../../lib/helpers/const");
12
+ const _error = require("../../lib/helpers/error");
13
+ const _flag = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/helpers/flag"));
14
+ const _object = require("../../lib/helpers/object");
15
+ const _request = require("../../lib/helpers/request");
16
+ const _string = require("../../lib/helpers/string");
17
+ const _ux = require("../../lib/helpers/ux");
18
+ const _emailLayout = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/email-layout"));
19
+ const _validate = /*#__PURE__*/ _interopRequireDefault(require("./validate"));
20
+ function _interopRequireDefault(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ function _getRequireWildcardCache(nodeInterop) {
26
+ if (typeof WeakMap !== "function") return null;
27
+ var cacheBabelInterop = new WeakMap();
28
+ var cacheNodeInterop = new WeakMap();
29
+ return (_getRequireWildcardCache = function(nodeInterop) {
30
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
31
+ })(nodeInterop);
32
+ }
33
+ function _interopRequireWildcard(obj, nodeInterop) {
34
+ if (!nodeInterop && obj && obj.__esModule) {
35
+ return obj;
36
+ }
37
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
38
+ return {
39
+ default: obj
40
+ };
41
+ }
42
+ var cache = _getRequireWildcardCache(nodeInterop);
43
+ if (cache && cache.has(obj)) {
44
+ return cache.get(obj);
45
+ }
46
+ var newObj = {};
47
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
+ for(var key in obj){
49
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
50
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
51
+ if (desc && (desc.get || desc.set)) {
52
+ Object.defineProperty(newObj, key, desc);
53
+ } else {
54
+ newObj[key] = obj[key];
55
+ }
56
+ }
57
+ }
58
+ newObj.default = obj;
59
+ if (cache) {
60
+ cache.set(obj, newObj);
61
+ }
62
+ return newObj;
63
+ }
64
+ class EmailLayoutPush extends _baseCommand.default {
65
+ async run() {
66
+ const { flags } = this.props;
67
+ // 1. First read all layout directories found for the given command.
68
+ const target = await _emailLayout.ensureValidCommandTarget(this.props, this.runContext);
69
+ const [layouts, readErrors] = await _emailLayout.readAllForCommandTarget(target, {
70
+ withExtractedFiles: true
71
+ });
72
+ if (readErrors.length > 0) {
73
+ this.error((0, _error.formatErrors)(readErrors, {
74
+ prependBy: "\n\n"
75
+ }));
76
+ }
77
+ if (layouts.length === 0) {
78
+ this.error(`No layout directories found in ${target.context.abspath}`);
79
+ }
80
+ // 2. Then validate them all ahead of pushing them.
81
+ _ux.spinner.start(`‣ Validating`);
82
+ const apiErrors = await _validate.default.validateAll(this.apiV1, this.props, layouts);
83
+ if (apiErrors.length > 0) {
84
+ this.error((0, _error.formatErrors)(apiErrors, {
85
+ prependBy: "\n\n"
86
+ }));
87
+ }
88
+ _ux.spinner.stop();
89
+ // 3. Finally push up each layout, abort on the first error.
90
+ _ux.spinner.start(`‣ Pushing`);
91
+ for (const layout of layouts){
92
+ const props = (0, _object.merge)(this.props, {
93
+ flags: {
94
+ annotate: true
95
+ }
96
+ });
97
+ // eslint-disable-next-line no-await-in-loop
98
+ const resp = await this.apiV1.upsertEmailLayout(props, {
99
+ ...layout.content,
100
+ key: layout.key
101
+ });
102
+ if ((0, _request.isSuccessResp)(resp)) {
103
+ // Update the layout directory with the successfully pushed layout
104
+ // payload from the server.
105
+ // eslint-disable-next-line no-await-in-loop
106
+ await _emailLayout.writeEmailLayoutDirFromData(layout, resp.data.email_layout);
107
+ continue;
108
+ }
109
+ const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _emailLayout.emailLayoutJsonPath(layout), "ApiError");
110
+ this.error((0, _error.formatError)(error));
111
+ }
112
+ _ux.spinner.stop();
113
+ // 4. Display a success message.
114
+ const layoutKeys = layouts.map((l)=>l.key);
115
+ const actioned = flags.commit ? "pushed and committed" : "pushed";
116
+ this.log(`‣ Successfully ${actioned} ${layouts.length} layout(s):\n` + (0, _string.indentString)(layoutKeys.join("\n"), 4));
117
+ }
118
+ }
119
+ EmailLayoutPush.summary = "Push one or more email layouts from a local file system to Knock.";
120
+ EmailLayoutPush.flags = {
121
+ environment: _core.Flags.string({
122
+ summary: "Pushing an email layout is only allowed in the development environment",
123
+ default: _const.KnockEnv.Development,
124
+ options: [
125
+ _const.KnockEnv.Development
126
+ ]
127
+ }),
128
+ all: _core.Flags.boolean({
129
+ summary: "Whether to push all layouts from the target directory."
130
+ }),
131
+ "layouts-dir": _flag.dirPath({
132
+ summary: "The target directory path to find all layouts to push.",
133
+ dependsOn: [
134
+ "all"
135
+ ],
136
+ aliases: [
137
+ "email-layouts-dir"
138
+ ]
139
+ }),
140
+ commit: _core.Flags.boolean({
141
+ summary: "Push and commit the layout(s) at the same time"
142
+ }),
143
+ "commit-message": _core.Flags.string({
144
+ summary: "Use the given value as the commit message",
145
+ char: "m",
146
+ dependsOn: [
147
+ "commit"
148
+ ]
149
+ })
150
+ };
151
+ EmailLayoutPush.args = {
152
+ emailLayoutKey: _core.Args.string({
153
+ required: false
154
+ })
155
+ };
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>EmailLayoutValidate
8
+ });
9
+ const _core = require("@oclif/core");
10
+ const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
11
+ const _const = require("../../lib/helpers/const");
12
+ const _error = require("../../lib/helpers/error");
13
+ const _flag = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/helpers/flag"));
14
+ const _request = require("../../lib/helpers/request");
15
+ const _string = require("../../lib/helpers/string");
16
+ const _ux = require("../../lib/helpers/ux");
17
+ const _emailLayout = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/email-layout"));
18
+ function _interopRequireDefault(obj) {
19
+ return obj && obj.__esModule ? obj : {
20
+ default: obj
21
+ };
22
+ }
23
+ function _getRequireWildcardCache(nodeInterop) {
24
+ if (typeof WeakMap !== "function") return null;
25
+ var cacheBabelInterop = new WeakMap();
26
+ var cacheNodeInterop = new WeakMap();
27
+ return (_getRequireWildcardCache = function(nodeInterop) {
28
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
29
+ })(nodeInterop);
30
+ }
31
+ function _interopRequireWildcard(obj, nodeInterop) {
32
+ if (!nodeInterop && obj && obj.__esModule) {
33
+ return obj;
34
+ }
35
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
36
+ return {
37
+ default: obj
38
+ };
39
+ }
40
+ var cache = _getRequireWildcardCache(nodeInterop);
41
+ if (cache && cache.has(obj)) {
42
+ return cache.get(obj);
43
+ }
44
+ var newObj = {};
45
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
+ for(var key in obj){
47
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
48
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
49
+ if (desc && (desc.get || desc.set)) {
50
+ Object.defineProperty(newObj, key, desc);
51
+ } else {
52
+ newObj[key] = obj[key];
53
+ }
54
+ }
55
+ }
56
+ newObj.default = obj;
57
+ if (cache) {
58
+ cache.set(obj, newObj);
59
+ }
60
+ return newObj;
61
+ }
62
+ class EmailLayoutValidate extends _baseCommand.default {
63
+ async run() {
64
+ // 1. Read all layout directories found for the given command.
65
+ const target = await _emailLayout.ensureValidCommandTarget(this.props, this.runContext);
66
+ const [layouts, readErrors] = await _emailLayout.readAllForCommandTarget(target, {
67
+ withExtractedFiles: true
68
+ });
69
+ if (readErrors.length > 0) {
70
+ this.error((0, _error.formatErrors)(readErrors, {
71
+ prependBy: "\n\n"
72
+ }));
73
+ }
74
+ if (layouts.length === 0) {
75
+ this.error(`No layout directories found in ${target.context.abspath}`);
76
+ }
77
+ // 2. Validate each layout data
78
+ _ux.spinner.start(`‣ Validating`);
79
+ const apiErrors = await EmailLayoutValidate.validateAll(this.apiV1, this.props, layouts);
80
+ if (apiErrors.length > 0) {
81
+ this.error((0, _error.formatErrors)(apiErrors, {
82
+ prependBy: "\n\n"
83
+ }));
84
+ }
85
+ _ux.spinner.stop();
86
+ // 3. Display a success message.
87
+ const layoutsKey = layouts.map((l)=>l.key);
88
+ this.log(`‣ Successfully validated ${layouts.length} layout(s):\n` + (0, _string.indentString)(layoutsKey.join("\n"), 4));
89
+ }
90
+ static async validateAll(api, props, layouts) {
91
+ const errorPromises = layouts.map(async (layout)=>{
92
+ const resp = await api.validateEmailLayout(props, {
93
+ ...layout.content,
94
+ key: layout.key
95
+ });
96
+ if ((0, _request.isSuccessResp)(resp)) return;
97
+ const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _emailLayout.emailLayoutJsonPath(layout), "ApiError");
98
+ return error;
99
+ });
100
+ const errors = (await Promise.all(errorPromises)).filter((e)=>Boolean(e));
101
+ return errors;
102
+ }
103
+ }
104
+ EmailLayoutValidate.summary = "Validate one or more layouts from a local file system.";
105
+ EmailLayoutValidate.flags = {
106
+ environment: _core.Flags.string({
107
+ summary: "Validating a layout is only done in the development environment",
108
+ default: _const.KnockEnv.Development,
109
+ options: [
110
+ _const.KnockEnv.Development
111
+ ]
112
+ }),
113
+ all: _core.Flags.boolean({
114
+ summary: "Whether to validate all layouts from the target directory."
115
+ }),
116
+ "layouts-dir": _flag.dirPath({
117
+ summary: "The target directory path to find all layouts to validate.",
118
+ dependsOn: [
119
+ "all"
120
+ ],
121
+ aliases: [
122
+ "email-layouts-dir"
123
+ ]
124
+ })
125
+ };
126
+ EmailLayoutValidate.args = {
127
+ emailLayoutKey: _core.Args.string({
128
+ required: false
129
+ })
130
+ };
@@ -9,7 +9,10 @@ Object.defineProperty(exports, "default", {
9
9
  const _core = require("@oclif/core");
10
10
  const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
11
11
  const _date = require("../../lib/helpers/date");
12
+ const _error = require("../../lib/helpers/error");
12
13
  const _request = require("../../lib/helpers/request");
14
+ const _string = require("../../lib/helpers/string");
15
+ const _ux = require("../../lib/helpers/ux");
13
16
  const _conditions = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/conditions"));
14
17
  const _workflow = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/workflow"));
15
18
  function _interopRequireDefault(obj) {
@@ -58,12 +61,30 @@ function _interopRequireWildcard(obj, nodeInterop) {
58
61
  }
59
62
  class WorkflowGet extends _baseCommand.default {
60
63
  async run() {
61
- const resp = await (0, _request.withSpinner)(()=>this.apiV1.getWorkflow(this.props));
64
+ _ux.spinner.start("‣ Loading");
65
+ const { workflow , whoami } = await this.loadWorkflow();
66
+ _ux.spinner.stop();
62
67
  const { flags } = this.props;
63
- if (flags.json) return resp.data;
64
- this.render(resp.data);
68
+ if (flags.json) return workflow;
69
+ this.render(workflow, whoami);
65
70
  }
66
- render(workflow) {
71
+ async loadWorkflow() {
72
+ const workflowResp = await this.apiV1.getWorkflow(this.props);
73
+ if (!(0, _request.isSuccessResp)(workflowResp)) {
74
+ const message = (0, _request.formatErrorRespMessage)(workflowResp);
75
+ _core.ux.error(new _error.ApiError(message));
76
+ }
77
+ const whoamiResp = await this.apiV1.whoami();
78
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
79
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
80
+ _core.ux.error(new _error.ApiError(message));
81
+ }
82
+ return {
83
+ workflow: workflowResp.data,
84
+ whoami: whoamiResp.data
85
+ };
86
+ }
87
+ render(workflow, whoami) {
67
88
  const { workflowKey } = this.props.args;
68
89
  const { environment: env , "hide-uncommitted-changes": commitedOnly } = this.props.flags;
69
90
  const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
@@ -130,11 +151,13 @@ class WorkflowGet extends _baseCommand.default {
130
151
  },
131
152
  ref: {
132
153
  header: "Ref",
133
- minWidth: 18
154
+ minWidth: 18,
155
+ get: (step)=>step.ref
134
156
  },
135
157
  type: {
136
158
  header: "Type",
137
- minWidth: 12
159
+ minWidth: 12,
160
+ get: (step)=>step.type
138
161
  },
139
162
  summary: {
140
163
  header: "Summary",
@@ -142,9 +165,18 @@ class WorkflowGet extends _baseCommand.default {
142
165
  },
143
166
  conditions: {
144
167
  header: "Conditions",
145
- get: (step)=>step.conditions ? _conditions.formatConditions(step.conditions) : "-"
168
+ get: (step)=>{
169
+ if (step.type === _workflow.StepType.Branch) return "-";
170
+ if (!step.conditions) return "-";
171
+ return _conditions.formatConditions(step.conditions);
172
+ }
146
173
  }
147
174
  });
175
+ const hasTopLevelBranchStep = workflow.steps.some((step)=>step.type === _workflow.StepType.Branch);
176
+ 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:`;
177
+ const viewWorkflowUrl = `https://dashboard.knock.app/${whoami.account_slug}/${env.toLowerCase()}/workflows/${workflow.key}`;
178
+ this.log(dashboardLinkMessage);
179
+ this.log((0, _string.indentString)(viewWorkflowUrl, 2));
148
180
  }
149
181
  }
150
182
  WorkflowGet.summary = "Display a single workflow from an environment.";
@@ -98,7 +98,10 @@ class WorkflowList extends _baseCommand.default {
98
98
  },
99
99
  steps: {
100
100
  header: "Steps",
101
- get: (entry)=>entry.steps.length > 0 ? entry.steps.length : "-"
101
+ get: (entry)=>{
102
+ const result = _workflow.countSteps(entry);
103
+ return result > 0 ? result : "-";
104
+ }
102
105
  },
103
106
  updated_at: {
104
107
  header: "Updated at",
@@ -159,6 +159,53 @@ class ApiV1 {
159
159
  params
160
160
  });
161
161
  }
162
+ // By resources: Email layouts
163
+ async listEmailLayouts({ flags }) {
164
+ const params = (0, _object.prune)({
165
+ environment: flags.environment,
166
+ annotate: flags.annotate,
167
+ hide_uncommitted_changes: flags["hide-uncommitted-changes"],
168
+ ...(0, _page.toPageParams)(flags)
169
+ });
170
+ return this.get("/email_layouts", {
171
+ params
172
+ });
173
+ }
174
+ async getEmailLayout({ args , flags }) {
175
+ const params = (0, _object.prune)({
176
+ environment: flags.environment,
177
+ annotate: flags.annotate,
178
+ hide_uncommitted_changes: flags["hide-uncommitted-changes"]
179
+ });
180
+ return this.get(`/email_layouts/${args.emailLayoutKey}`, {
181
+ params
182
+ });
183
+ }
184
+ async upsertEmailLayout({ flags }, layout) {
185
+ const params = (0, _object.prune)({
186
+ environment: flags.environment,
187
+ annotate: flags.annotate,
188
+ commit: flags.commit,
189
+ commit_message: flags["commit-message"]
190
+ });
191
+ const data = {
192
+ email_layout: layout
193
+ };
194
+ return this.put(`/email_layouts/${layout.key}`, data, {
195
+ params
196
+ });
197
+ }
198
+ async validateEmailLayout({ flags }, layout) {
199
+ const params = (0, _object.prune)({
200
+ environment: flags.environment
201
+ });
202
+ const data = {
203
+ email_layout: layout
204
+ };
205
+ return this.put(`/email_layouts/${layout.key}/validate`, data, {
206
+ params
207
+ });
208
+ }
162
209
  // By methods:
163
210
  async get(subpath, config) {
164
211
  return this.client.get(`/${API_VERSION}` + subpath, config);
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ LAYOUT_JSON: ()=>LAYOUT_JSON,
13
+ emailLayoutJsonPath: ()=>emailLayoutJsonPath,
14
+ isEmailLayoutDir: ()=>isEmailLayoutDir,
15
+ lsEmailLayoutJson: ()=>lsEmailLayoutJson,
16
+ ensureValidCommandTarget: ()=>ensureValidCommandTarget
17
+ });
18
+ const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
19
+ const _core = require("@oclif/core");
20
+ const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
21
+ function _getRequireWildcardCache(nodeInterop) {
22
+ if (typeof WeakMap !== "function") return null;
23
+ var cacheBabelInterop = new WeakMap();
24
+ var cacheNodeInterop = new WeakMap();
25
+ return (_getRequireWildcardCache = function(nodeInterop) {
26
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
+ })(nodeInterop);
28
+ }
29
+ function _interopRequireWildcard(obj, nodeInterop) {
30
+ if (!nodeInterop && obj && obj.__esModule) {
31
+ return obj;
32
+ }
33
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
34
+ return {
35
+ default: obj
36
+ };
37
+ }
38
+ var cache = _getRequireWildcardCache(nodeInterop);
39
+ if (cache && cache.has(obj)) {
40
+ return cache.get(obj);
41
+ }
42
+ var newObj = {};
43
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
44
+ for(var key in obj){
45
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
46
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
47
+ if (desc && (desc.get || desc.set)) {
48
+ Object.defineProperty(newObj, key, desc);
49
+ } else {
50
+ newObj[key] = obj[key];
51
+ }
52
+ }
53
+ }
54
+ newObj.default = obj;
55
+ if (cache) {
56
+ cache.set(obj, newObj);
57
+ }
58
+ return newObj;
59
+ }
60
+ const LAYOUT_JSON = "layout.json";
61
+ const emailLayoutJsonPath = (layoutDirCtx)=>_nodePath.resolve(layoutDirCtx.abspath, LAYOUT_JSON);
62
+ const isEmailLayoutDir = async (dirPath)=>Boolean(await lsEmailLayoutJson(dirPath));
63
+ const lsEmailLayoutJson = async (dirPath)=>{
64
+ const emailLayoutJsonPath = _nodePath.resolve(dirPath, LAYOUT_JSON);
65
+ const exists = await _fsExtra.pathExists(emailLayoutJsonPath);
66
+ return exists ? emailLayoutJsonPath : undefined;
67
+ };
68
+ const ensureValidCommandTarget = async (props, runContext)=>{
69
+ const { args , flags } = props;
70
+ const { commandId , resourceDir: resourceDirCtx , cwd: runCwd } = runContext;
71
+ // If the target resource is a different type than the current resource dir
72
+ // type, error out.
73
+ if (resourceDirCtx && resourceDirCtx.type !== "email_layout") {
74
+ return _core.ux.error(`Cannot run ${commandId} inside a ${resourceDirCtx.type} directory`);
75
+ }
76
+ // Cannot accept both email layout key arg and --all flag.
77
+ if (flags.all && args.emailLayoutKey) {
78
+ return _core.ux.error(`emailLayoutKey arg \`${args.emailLayoutKey}\` cannot also be provided when using --all`);
79
+ }
80
+ // --all flag is given, which means no layout key arg.
81
+ if (flags.all) {
82
+ // If --all flag used inside a layout directory, then require a layouts dir path.
83
+ if (resourceDirCtx && !flags["layouts-dir"]) {
84
+ return _core.ux.error("Missing required flag layouts-dir");
85
+ }
86
+ // Targeting all layout dirs in the layouts index dir.
87
+ // TODO: Default to the knock project config first if present before cwd.
88
+ const defaultToCwd = {
89
+ abspath: runCwd,
90
+ exists: true
91
+ };
92
+ const indexDirCtx = flags["layouts-dir"] || defaultToCwd;
93
+ return {
94
+ type: "emailLayoutsIndexDir",
95
+ context: indexDirCtx
96
+ };
97
+ }
98
+ // Email layout key arg is given, which means no --all flag.
99
+ if (args.emailLayoutKey) {
100
+ if (resourceDirCtx && resourceDirCtx.key !== args.emailLayoutKey) {
101
+ return _core.ux.error(`Cannot run ${commandId} \`${args.emailLayoutKey}\` inside another layout directory:\n${resourceDirCtx.key}`);
102
+ }
103
+ const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : _nodePath.resolve(runCwd, args.emailLayoutKey);
104
+ const layoutDirCtx = {
105
+ type: "email_layout",
106
+ key: args.emailLayoutKey,
107
+ abspath: targetDirPath,
108
+ exists: await isEmailLayoutDir(targetDirPath)
109
+ };
110
+ return {
111
+ type: "emailLayoutDir",
112
+ context: layoutDirCtx
113
+ };
114
+ }
115
+ // From this point on, we have neither an email layout key arg nor --all flag.
116
+ // If running inside a layout directory, then use that.
117
+ if (resourceDirCtx) {
118
+ return {
119
+ type: "emailLayoutDir",
120
+ context: resourceDirCtx
121
+ };
122
+ }
123
+ return _core.ux.error("Missing 1 required arg:emailLayoutKey");
124
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _exportStar(require("./helpers"), exports);
6
+ _exportStar(require("./reader"), exports);
7
+ _exportStar(require("./types"), exports);
8
+ _exportStar(require("./writer"), exports);
9
+ function _exportStar(from, to) {
10
+ Object.keys(from).forEach(function(k) {
11
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
12
+ enumerable: true,
13
+ get: function() {
14
+ return from[k];
15
+ }
16
+ });
17
+ });
18
+ return from;
19
+ }