@knocklabs/cli 0.1.6 → 0.1.8
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 +74 -30
- package/dist/commands/commit/get.js +76 -0
- package/dist/commands/commit/list.js +99 -0
- package/dist/commands/commit/promote.js +36 -3
- package/dist/commands/layout/list.js +2 -2
- package/dist/commands/layout/pull.js +3 -3
- package/dist/commands/layout/push.js +2 -2
- package/dist/commands/translation/list.js +2 -2
- package/dist/commands/translation/pull.js +2 -2
- package/dist/commands/workflow/list.js +2 -2
- package/dist/commands/workflow/new.js +2 -2
- package/dist/commands/workflow/pull.js +3 -3
- package/dist/commands/workflow/push.js +2 -2
- package/dist/lib/api-v1.js +34 -18
- package/dist/lib/helpers/{object.js → object.isomorphic.js} +8 -1
- package/dist/lib/marshal/commit/helpers.js +13 -0
- package/dist/lib/marshal/commit/index.js +17 -0
- package/dist/lib/marshal/commit/types.js +5 -0
- package/dist/lib/marshal/email-layout/reader.js +7 -6
- package/dist/lib/marshal/email-layout/writer.js +12 -12
- package/dist/lib/marshal/shared/const.isomorphic.js +25 -0
- package/dist/lib/marshal/shared/helpers.js +0 -4
- package/dist/lib/marshal/workflow/generator.js +8 -8
- package/dist/lib/marshal/workflow/helpers.js +3 -6
- package/dist/lib/marshal/workflow/index.js +1 -0
- package/dist/lib/marshal/workflow/processor.isomorphic.js +272 -0
- package/dist/lib/marshal/workflow/reader.js +11 -9
- package/dist/lib/marshal/workflow/writer.js +7 -238
- package/oclif.manifest.json +111 -4
- package/package.json +8 -8
|
@@ -10,7 +10,7 @@ const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
|
|
|
10
10
|
const _core = require("@oclif/core");
|
|
11
11
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
12
12
|
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
|
|
13
|
-
const
|
|
13
|
+
const _objectIsomorphic = require("../../lib/helpers/object.isomorphic");
|
|
14
14
|
const _ux = require("../../lib/helpers/ux");
|
|
15
15
|
const _workflow = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/workflow"));
|
|
16
16
|
function _interopRequireDefault(obj) {
|
|
@@ -106,7 +106,7 @@ class WorkflowNew extends _baseCommand.default {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
async checkExistingWorkflow() {
|
|
109
|
-
const props = (0,
|
|
109
|
+
const props = (0, _objectIsomorphic.merge)(this.props, {
|
|
110
110
|
flags: {
|
|
111
111
|
environment: "development"
|
|
112
112
|
}
|
|
@@ -11,7 +11,7 @@ const _core = require("@oclif/core");
|
|
|
11
11
|
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
|
|
12
12
|
const _error = require("../../lib/helpers/error");
|
|
13
13
|
const _flag = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/helpers/flag"));
|
|
14
|
-
const
|
|
14
|
+
const _objectIsomorphic = require("../../lib/helpers/object.isomorphic");
|
|
15
15
|
const _page = require("../../lib/helpers/page");
|
|
16
16
|
const _request = require("../../lib/helpers/request");
|
|
17
17
|
const _ux = require("../../lib/helpers/ux");
|
|
@@ -84,7 +84,7 @@ class WorkflowPull extends _baseCommand.default {
|
|
|
84
84
|
}
|
|
85
85
|
// 2. Fetch the workflow with annotations.
|
|
86
86
|
const resp = await (0, _request.withSpinner)(()=>{
|
|
87
|
-
const props = (0,
|
|
87
|
+
const props = (0, _objectIsomorphic.merge)(this.props, {
|
|
88
88
|
args: {
|
|
89
89
|
workflowKey: dirContext.key
|
|
90
90
|
},
|
|
@@ -149,7 +149,7 @@ class WorkflowPull extends _baseCommand.default {
|
|
|
149
149
|
this.log(`‣ Successfully ${action} the workflows directory at ${targetDirCtx.abspath}`);
|
|
150
150
|
}
|
|
151
151
|
async listAllWorkflows(pageParams = {}, workflowsFetchedSoFar = []) {
|
|
152
|
-
const props = (0,
|
|
152
|
+
const props = (0, _objectIsomorphic.merge)(this.props, {
|
|
153
153
|
flags: {
|
|
154
154
|
...pageParams,
|
|
155
155
|
annotate: true,
|
|
@@ -11,7 +11,7 @@ const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/bas
|
|
|
11
11
|
const _const = require("../../lib/helpers/const");
|
|
12
12
|
const _error = require("../../lib/helpers/error");
|
|
13
13
|
const _flag = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/helpers/flag"));
|
|
14
|
-
const
|
|
14
|
+
const _objectIsomorphic = require("../../lib/helpers/object.isomorphic");
|
|
15
15
|
const _request = require("../../lib/helpers/request");
|
|
16
16
|
const _string = require("../../lib/helpers/string");
|
|
17
17
|
const _ux = require("../../lib/helpers/ux");
|
|
@@ -89,7 +89,7 @@ class WorkflowPush extends _baseCommand.default {
|
|
|
89
89
|
// 3. Finally push up each workflow, abort on the first error.
|
|
90
90
|
_ux.spinner.start(`‣ Pushing`);
|
|
91
91
|
for (const workflow of workflows){
|
|
92
|
-
const props = (0,
|
|
92
|
+
const props = (0, _objectIsomorphic.merge)(this.props, {
|
|
93
93
|
flags: {
|
|
94
94
|
annotate: true
|
|
95
95
|
}
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "default", {
|
|
|
7
7
|
get: ()=>ApiV1
|
|
8
8
|
});
|
|
9
9
|
const _axios = /*#__PURE__*/ _interopRequireDefault(require("axios"));
|
|
10
|
-
const
|
|
10
|
+
const _objectIsomorphic = require("./helpers/object.isomorphic");
|
|
11
11
|
const _page = require("./helpers/page");
|
|
12
12
|
function _interopRequireDefault(obj) {
|
|
13
13
|
return obj && obj.__esModule ? obj : {
|
|
@@ -25,7 +25,7 @@ class ApiV1 {
|
|
|
25
25
|
}
|
|
26
26
|
// By resources: Workflows
|
|
27
27
|
async listWorkflows({ flags }) {
|
|
28
|
-
const params = (0,
|
|
28
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
29
29
|
environment: flags.environment,
|
|
30
30
|
annotate: flags.annotate,
|
|
31
31
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
@@ -36,7 +36,7 @@ class ApiV1 {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
async getWorkflow({ args , flags }) {
|
|
39
|
-
const params = (0,
|
|
39
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
40
40
|
environment: flags.environment,
|
|
41
41
|
annotate: flags.annotate,
|
|
42
42
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
@@ -46,7 +46,7 @@ class ApiV1 {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
async upsertWorkflow({ flags }, workflow) {
|
|
49
|
-
const params = (0,
|
|
49
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
50
50
|
environment: flags.environment,
|
|
51
51
|
annotate: flags.annotate,
|
|
52
52
|
commit: flags.commit,
|
|
@@ -60,7 +60,7 @@ class ApiV1 {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
async validateWorkflow({ flags }, workflow) {
|
|
63
|
-
const params = (0,
|
|
63
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
64
64
|
environment: flags.environment
|
|
65
65
|
});
|
|
66
66
|
const data = {
|
|
@@ -71,7 +71,7 @@ class ApiV1 {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
async activateWorkflow({ args , flags }) {
|
|
74
|
-
const params = (0,
|
|
74
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
75
75
|
environment: flags.environment,
|
|
76
76
|
status: flags.status
|
|
77
77
|
});
|
|
@@ -80,10 +80,10 @@ class ApiV1 {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
async runWorkflow({ args , flags }) {
|
|
83
|
-
const params = (0,
|
|
83
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
84
84
|
environment: flags.environment
|
|
85
85
|
});
|
|
86
|
-
const data = (0,
|
|
86
|
+
const data = (0, _objectIsomorphic.prune)({
|
|
87
87
|
recipients: flags.recipients,
|
|
88
88
|
tenant: flags.tenant,
|
|
89
89
|
data: flags.data,
|
|
@@ -94,8 +94,21 @@ class ApiV1 {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
// By resources: Commits
|
|
97
|
+
async listCommits({ flags }) {
|
|
98
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
99
|
+
environment: flags.environment,
|
|
100
|
+
promoted: flags.promoted,
|
|
101
|
+
...(0, _page.toPageParams)(flags)
|
|
102
|
+
});
|
|
103
|
+
return this.get("/commits", {
|
|
104
|
+
params
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async getCommit({ args }) {
|
|
108
|
+
return this.get(`/commits/${args.id}`);
|
|
109
|
+
}
|
|
97
110
|
async commitAllChanges({ flags }) {
|
|
98
|
-
const params = (0,
|
|
111
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
99
112
|
environment: flags.environment,
|
|
100
113
|
commit_message: flags["commit-message"]
|
|
101
114
|
});
|
|
@@ -104,16 +117,19 @@ class ApiV1 {
|
|
|
104
117
|
});
|
|
105
118
|
}
|
|
106
119
|
async promoteAllChanges({ flags }) {
|
|
107
|
-
const params = (0,
|
|
120
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
108
121
|
to_environment: flags.to
|
|
109
122
|
});
|
|
110
123
|
return this.put(`/commits/promote`, {}, {
|
|
111
124
|
params
|
|
112
125
|
});
|
|
113
126
|
}
|
|
127
|
+
async promoteOneChange({ flags }) {
|
|
128
|
+
return this.put(`/commits/${flags.only}/promote`);
|
|
129
|
+
}
|
|
114
130
|
// By resources: Translations
|
|
115
131
|
async listTranslations({ flags }, filters = {}) {
|
|
116
|
-
const params = (0,
|
|
132
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
117
133
|
environment: flags.environment,
|
|
118
134
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
119
135
|
locale_code: filters.localeCode,
|
|
@@ -125,7 +141,7 @@ class ApiV1 {
|
|
|
125
141
|
});
|
|
126
142
|
}
|
|
127
143
|
async getTranslation({ flags }, translation) {
|
|
128
|
-
const params = (0,
|
|
144
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
129
145
|
environment: flags.environment,
|
|
130
146
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
131
147
|
namespace: translation.namespace
|
|
@@ -135,7 +151,7 @@ class ApiV1 {
|
|
|
135
151
|
});
|
|
136
152
|
}
|
|
137
153
|
async upsertTranslation({ flags }, translation) {
|
|
138
|
-
const params = (0,
|
|
154
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
139
155
|
environment: flags.environment,
|
|
140
156
|
commit: flags.commit,
|
|
141
157
|
commit_message: flags["commit-message"],
|
|
@@ -148,7 +164,7 @@ class ApiV1 {
|
|
|
148
164
|
});
|
|
149
165
|
}
|
|
150
166
|
async validateTranslation({ flags }, translation) {
|
|
151
|
-
const params = (0,
|
|
167
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
152
168
|
environment: flags.environment,
|
|
153
169
|
namespace: translation.namespace
|
|
154
170
|
});
|
|
@@ -161,7 +177,7 @@ class ApiV1 {
|
|
|
161
177
|
}
|
|
162
178
|
// By resources: Email layouts
|
|
163
179
|
async listEmailLayouts({ flags }) {
|
|
164
|
-
const params = (0,
|
|
180
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
165
181
|
environment: flags.environment,
|
|
166
182
|
annotate: flags.annotate,
|
|
167
183
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
@@ -172,7 +188,7 @@ class ApiV1 {
|
|
|
172
188
|
});
|
|
173
189
|
}
|
|
174
190
|
async getEmailLayout({ args , flags }) {
|
|
175
|
-
const params = (0,
|
|
191
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
176
192
|
environment: flags.environment,
|
|
177
193
|
annotate: flags.annotate,
|
|
178
194
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"]
|
|
@@ -182,7 +198,7 @@ class ApiV1 {
|
|
|
182
198
|
});
|
|
183
199
|
}
|
|
184
200
|
async upsertEmailLayout({ flags }, layout) {
|
|
185
|
-
const params = (0,
|
|
201
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
186
202
|
environment: flags.environment,
|
|
187
203
|
annotate: flags.annotate,
|
|
188
204
|
commit: flags.commit,
|
|
@@ -196,7 +212,7 @@ class ApiV1 {
|
|
|
196
212
|
});
|
|
197
213
|
}
|
|
198
214
|
async validateEmailLayout({ flags }, layout) {
|
|
199
|
-
const params = (0,
|
|
215
|
+
const params = (0, _objectIsomorphic.prune)({
|
|
200
216
|
environment: flags.environment
|
|
201
217
|
});
|
|
202
218
|
const data = {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT:
|
|
3
|
+
*
|
|
4
|
+
* This file is suffixed with `.isomorphic` because the code in this file is
|
|
5
|
+
* meant to run not just in a nodejs environment but also in a browser. For this
|
|
6
|
+
* reason there are some restrictions for which nodejs imports are allowed in
|
|
7
|
+
* this module. See `.eslintrc.json` for more details.
|
|
8
|
+
*/ "use strict";
|
|
2
9
|
Object.defineProperty(exports, "__esModule", {
|
|
3
10
|
value: true
|
|
4
11
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatCommitAuthor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>formatCommitAuthor
|
|
8
|
+
});
|
|
9
|
+
function formatCommitAuthor(commit) {
|
|
10
|
+
const email = commit.author.email;
|
|
11
|
+
const name = commit.author.name;
|
|
12
|
+
return name ? `${name} <${email}>` : `<${email}>`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_exportStar(require("./helpers"), exports);
|
|
6
|
+
_exportStar(require("./types"), exports);
|
|
7
|
+
function _exportStar(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return from;
|
|
17
|
+
}
|
|
@@ -18,7 +18,8 @@ const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
|
18
18
|
const _lodash = require("lodash");
|
|
19
19
|
const _error = require("../../helpers/error");
|
|
20
20
|
const _json = require("../../helpers/json");
|
|
21
|
-
const
|
|
21
|
+
const _objectIsomorphic = require("../../helpers/object.isomorphic");
|
|
22
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
22
23
|
const _helpers = require("../shared/helpers");
|
|
23
24
|
const _helpers1 = require("./helpers");
|
|
24
25
|
function _interopRequireDefault(obj) {
|
|
@@ -135,7 +136,7 @@ const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
|
|
|
135
136
|
const result = await (0, _json.readJson)(layoutJsonPath);
|
|
136
137
|
if (!result[0]) return result;
|
|
137
138
|
let [layoutJson] = result;
|
|
138
|
-
layoutJson = withReadonlyField ? layoutJson : (0,
|
|
139
|
+
layoutJson = withReadonlyField ? layoutJson : (0, _objectIsomorphic.omitDeep)(layoutJson, [
|
|
139
140
|
"__readonly"
|
|
140
141
|
]);
|
|
141
142
|
return withExtractedFiles ? joinExtractedFiles(layoutDirCtx, layoutJson) : [
|
|
@@ -153,11 +154,11 @@ const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
|
|
|
153
154
|
// layout.json) in the layout json node. Mutated in place, and used
|
|
154
155
|
// to validate the uniqueness of an extracted path encountered.
|
|
155
156
|
const uniqueFilePaths = {};
|
|
156
|
-
(0,
|
|
157
|
+
(0, _objectIsomorphic.mapValuesDeep)(layoutJson, (relpath, key, parts)=>{
|
|
157
158
|
// If not marked with the @suffix, there's nothing to do.
|
|
158
|
-
if (!
|
|
159
|
-
const objPathToFieldStr =
|
|
160
|
-
const inlinObjPathStr = objPathToFieldStr.replace(
|
|
159
|
+
if (!_constIsomorphic.FILEPATH_MARKED_RE.test(key)) return;
|
|
160
|
+
const objPathToFieldStr = _objectIsomorphic.ObjPath.stringify(parts);
|
|
161
|
+
const inlinObjPathStr = objPathToFieldStr.replace(_constIsomorphic.FILEPATH_MARKED_RE, "");
|
|
161
162
|
// If there is inlined content present already, then nothing more to do.
|
|
162
163
|
if ((0, _lodash.hasIn)(layoutJson, inlinObjPathStr)) return;
|
|
163
164
|
// Check if the extracted path found at the current field path is valid
|
|
@@ -20,9 +20,9 @@ const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
|
20
20
|
const _lodash = require("lodash");
|
|
21
21
|
const _const = require("../../helpers/const");
|
|
22
22
|
const _json = require("../../helpers/json");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const _objectIsomorphic = require("../../helpers/object.isomorphic");
|
|
24
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
25
|
+
const _helpers = require("./helpers");
|
|
26
26
|
const _reader = require("./reader");
|
|
27
27
|
function _interopRequireDefault(obj) {
|
|
28
28
|
return obj && obj.__esModule ? obj : {
|
|
@@ -96,13 +96,13 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
96
96
|
var _emailLayout___annotation;
|
|
97
97
|
// Move read only field under the dedicated field "__readonly".
|
|
98
98
|
const readonlyFields = ((_emailLayout___annotation = emailLayout.__annotation) === null || _emailLayout___annotation === void 0 ? void 0 : _emailLayout___annotation.readonly_fields) || [];
|
|
99
|
-
const [readonly, remainder] = (0,
|
|
99
|
+
const [readonly, remainder] = (0, _objectIsomorphic.split)(emailLayout, readonlyFields);
|
|
100
100
|
const emailLayoutjson = {
|
|
101
101
|
...remainder,
|
|
102
102
|
__readonly: readonly
|
|
103
103
|
};
|
|
104
104
|
// Strip out all schema annotations, so not to expose them to end users.
|
|
105
|
-
return (0,
|
|
105
|
+
return (0, _objectIsomorphic.omitDeep)(emailLayoutjson, [
|
|
106
106
|
"__annotation"
|
|
107
107
|
]);
|
|
108
108
|
};
|
|
@@ -122,7 +122,7 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
|
|
|
122
122
|
}
|
|
123
123
|
const promises = Object.entries(bundle).map(([relpath, fileContent])=>{
|
|
124
124
|
const filePath = _nodePath.default.resolve(emailLayoutDirCtx.abspath, relpath);
|
|
125
|
-
return relpath ===
|
|
125
|
+
return relpath === _helpers.LAYOUT_JSON ? _fsExtra.outputJson(filePath, fileContent, {
|
|
126
126
|
spaces: _json.DOUBLE_SPACES
|
|
127
127
|
}) : _fsExtra.outputFile(filePath, fileContent);
|
|
128
128
|
});
|
|
@@ -158,8 +158,8 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
|
|
|
158
158
|
if (!(0, _lodash.has)(mutRemoteEmailLayout, objPathParts)) continue;
|
|
159
159
|
// If the field at this path is extracted in the local layout, then
|
|
160
160
|
// always extract; otherwise extract based on the field settings default.
|
|
161
|
-
const objPathStr =
|
|
162
|
-
const extractedFilePath = (0, _lodash.get)(localEmailLayout, `${objPathStr}${
|
|
161
|
+
const objPathStr = _objectIsomorphic.ObjPath.stringify(objPathParts);
|
|
162
|
+
const extractedFilePath = (0, _lodash.get)(localEmailLayout, `${objPathStr}${_constIsomorphic.FILEPATH_MARKER}`);
|
|
163
163
|
const { default: extractByDefault , file_ext: fileExt } = extractionSettings;
|
|
164
164
|
if (!extractedFilePath && !extractByDefault) continue;
|
|
165
165
|
// By this point, we have a field where we need to extract its content.
|
|
@@ -175,13 +175,13 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
|
|
|
175
175
|
(0, _lodash.set)(bundle, [
|
|
176
176
|
relpath
|
|
177
177
|
], data);
|
|
178
|
-
(0, _lodash.set)(mutRemoteEmailLayout, `${objPathStr}${
|
|
178
|
+
(0, _lodash.set)(mutRemoteEmailLayout, `${objPathStr}${_constIsomorphic.FILEPATH_MARKER}`, relpath);
|
|
179
179
|
(0, _lodash.unset)(mutRemoteEmailLayout, objPathStr);
|
|
180
180
|
}
|
|
181
181
|
// At this point the bundle contains all extractable files, so we finally add the layout
|
|
182
182
|
// JSON realtive path + the file content.
|
|
183
183
|
return (0, _lodash.set)(bundle, [
|
|
184
|
-
|
|
184
|
+
_helpers.LAYOUT_JSON
|
|
185
185
|
], toEmailLayoutJson(mutRemoteEmailLayout));
|
|
186
186
|
};
|
|
187
187
|
const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
@@ -197,7 +197,7 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
|
197
197
|
type: "email_layout",
|
|
198
198
|
key: remoteEmailLayout.key,
|
|
199
199
|
abspath: emailLayoutDirPath,
|
|
200
|
-
exists: indexDirCtx.exists ? await (0,
|
|
200
|
+
exists: indexDirCtx.exists ? await (0, _helpers.isEmailLayoutDir)(emailLayoutDirPath) : false
|
|
201
201
|
};
|
|
202
202
|
return writeEmailLayoutDirFromData(emailLayoutDirCtx, remoteEmailLayout);
|
|
203
203
|
});
|
|
@@ -231,7 +231,7 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
|
231
231
|
const promises = dirents.map(async (dirent)=>{
|
|
232
232
|
const direntName = dirent.name.toLowerCase();
|
|
233
233
|
const direntPath = _nodePath.default.resolve(indexDirCtx.abspath, direntName);
|
|
234
|
-
if (await (0,
|
|
234
|
+
if (await (0, _helpers.isEmailLayoutDir)(direntPath) && emailLayoutsByKey[direntName]) {
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
await _fsExtra.remove(direntPath);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT:
|
|
3
|
+
*
|
|
4
|
+
* This file is suffixed with `.isomorphic` because the code in this file is
|
|
5
|
+
* meant to run not just in a nodejs environment but also in a browser. For this
|
|
6
|
+
* reason there are some restrictions for which nodejs imports are allowed in
|
|
7
|
+
* this module. See `.eslintrc.json` for more details.
|
|
8
|
+
*/ // Mark any template fields we are extracting out with this suffix as a rule,
|
|
9
|
+
// so we can reliably interpret the field value.
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
function _export(target, all) {
|
|
15
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: all[name]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_export(exports, {
|
|
21
|
+
FILEPATH_MARKER: ()=>FILEPATH_MARKER,
|
|
22
|
+
FILEPATH_MARKED_RE: ()=>FILEPATH_MARKED_RE
|
|
23
|
+
});
|
|
24
|
+
const FILEPATH_MARKER = "@";
|
|
25
|
+
const FILEPATH_MARKED_RE = new RegExp(`${FILEPATH_MARKER}$`);
|
|
@@ -9,8 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
FILEPATH_MARKER: ()=>FILEPATH_MARKER,
|
|
13
|
-
FILEPATH_MARKED_RE: ()=>FILEPATH_MARKED_RE,
|
|
14
12
|
readExtractedFileSync: ()=>readExtractedFileSync,
|
|
15
13
|
validateExtractedFilePath: ()=>validateExtractedFilePath,
|
|
16
14
|
checkIfValidExtractedFilePathFormat: ()=>checkIfValidExtractedFilePathFormat
|
|
@@ -60,8 +58,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
60
58
|
}
|
|
61
59
|
return newObj;
|
|
62
60
|
}
|
|
63
|
-
const FILEPATH_MARKER = "@";
|
|
64
|
-
const FILEPATH_MARKED_RE = new RegExp(`${FILEPATH_MARKER}$`);
|
|
65
61
|
// The following files are exepected to have valid json content, and should be
|
|
66
62
|
// decoded and joined into the main JSON file.
|
|
67
63
|
const DECODABLE_JSON_FILES = new Set([
|
|
@@ -15,8 +15,8 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
|
|
17
17
|
const _lodash = require("lodash");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
19
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
20
20
|
const _types = require("./types");
|
|
21
21
|
const _writer = require("./writer");
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -119,7 +119,7 @@ const scaffoldEmailChannelStep = (refSuffix)=>{
|
|
|
119
119
|
layout_key: "default"
|
|
120
120
|
},
|
|
121
121
|
subject: "You've got mail!",
|
|
122
|
-
["html_body" +
|
|
122
|
+
["html_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
const bundleFragment = {
|
|
@@ -139,7 +139,7 @@ const scaffoldInAppFeedChannelStep = (refSuffix)=>{
|
|
|
139
139
|
channel_key: "<IN-APP-FEED CHANNEL KEY>",
|
|
140
140
|
template: {
|
|
141
141
|
action_url: "{{ vars.app_url }}",
|
|
142
|
-
["markdown_body" +
|
|
142
|
+
["markdown_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
const bundleFragment = {
|
|
@@ -158,7 +158,7 @@ const scaffoldSmsChannelStep = (refSuffix)=>{
|
|
|
158
158
|
type: _types.StepType.Channel,
|
|
159
159
|
channel_key: "<SMS CHANNEL KEY>",
|
|
160
160
|
template: {
|
|
161
|
-
["text_body" +
|
|
161
|
+
["text_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
const bundleFragment = {
|
|
@@ -180,7 +180,7 @@ const scaffoldPushChannelStep = (refSuffix)=>{
|
|
|
180
180
|
settings: {
|
|
181
181
|
delivery_type: "content"
|
|
182
182
|
},
|
|
183
|
-
["text_body" +
|
|
183
|
+
["text_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
const bundleFragment = {
|
|
@@ -199,7 +199,7 @@ const scaffoldChatChannelStep = (refSuffix)=>{
|
|
|
199
199
|
type: _types.StepType.Channel,
|
|
200
200
|
channel_key: "<CHAT CHANNEL KEY>",
|
|
201
201
|
template: {
|
|
202
|
-
["markdown_body" +
|
|
202
|
+
["markdown_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
const bundleFragment = {
|
|
@@ -264,7 +264,7 @@ const scaffoldWorkflowDirBundle = (attrs)=>{
|
|
|
264
264
|
steps: scaffoldedSteps
|
|
265
265
|
};
|
|
266
266
|
return (0, _lodash.assign)({
|
|
267
|
-
[
|
|
267
|
+
[_processorIsomorphic.WORKFLOW_JSON]: workflowJson
|
|
268
268
|
}, ...bundleFragments);
|
|
269
269
|
};
|
|
270
270
|
const generateWorkflowDir = async (workflowDirCtx, attrs)=>{
|
|
@@ -9,8 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
WORKFLOW_JSON: ()=>WORKFLOW_JSON,
|
|
13
|
-
VISUAL_BLOCKS_JSON: ()=>VISUAL_BLOCKS_JSON,
|
|
14
12
|
workflowJsonPath: ()=>workflowJsonPath,
|
|
15
13
|
validateWorkflowKey: ()=>validateWorkflowKey,
|
|
16
14
|
lsWorkflowJson: ()=>lsWorkflowJson,
|
|
@@ -26,6 +24,7 @@ const _core = require("@oclif/core");
|
|
|
26
24
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
27
25
|
const _lodash = require("lodash");
|
|
28
26
|
const _string = require("../../helpers/string");
|
|
27
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
29
28
|
const _types = require("./types");
|
|
30
29
|
function _getRequireWildcardCache(nodeInterop) {
|
|
31
30
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -66,9 +65,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
65
|
}
|
|
67
66
|
return newObj;
|
|
68
67
|
}
|
|
69
|
-
const
|
|
70
|
-
const VISUAL_BLOCKS_JSON = "visual_blocks.json";
|
|
71
|
-
const workflowJsonPath = (workflowDirCtx)=>_nodePath.resolve(workflowDirCtx.abspath, WORKFLOW_JSON);
|
|
68
|
+
const workflowJsonPath = (workflowDirCtx)=>_nodePath.resolve(workflowDirCtx.abspath, _processorIsomorphic.WORKFLOW_JSON);
|
|
72
69
|
const validateWorkflowKey = (input)=>{
|
|
73
70
|
if (!(0, _string.checkSlugifiedFormat)(input, {
|
|
74
71
|
onlyLowerCase: true
|
|
@@ -78,7 +75,7 @@ const validateWorkflowKey = (input)=>{
|
|
|
78
75
|
return undefined;
|
|
79
76
|
};
|
|
80
77
|
const lsWorkflowJson = async (dirPath)=>{
|
|
81
|
-
const workflowJsonPath = _nodePath.resolve(dirPath, WORKFLOW_JSON);
|
|
78
|
+
const workflowJsonPath = _nodePath.resolve(dirPath, _processorIsomorphic.WORKFLOW_JSON);
|
|
82
79
|
const exists = await _fsExtra.pathExists(workflowJsonPath);
|
|
83
80
|
return exists ? workflowJsonPath : undefined;
|
|
84
81
|
};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
_exportStar(require("./generator"), exports);
|
|
6
6
|
_exportStar(require("./helpers"), exports);
|
|
7
|
+
_exportStar(require("./processor.isomorphic"), exports);
|
|
7
8
|
_exportStar(require("./reader"), exports);
|
|
8
9
|
_exportStar(require("./types"), exports);
|
|
9
10
|
_exportStar(require("./writer"), exports);
|