@knocklabs/cli 0.1.10 → 0.1.12
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 +16 -16
- 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
|
@@ -9,20 +9,24 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
readAllForCommandTarget: function() {
|
|
13
|
+
return readAllForCommandTarget;
|
|
14
|
+
},
|
|
15
|
+
readWorkflowDir: function() {
|
|
16
|
+
return readWorkflowDir;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const
|
|
19
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
16
20
|
const _core = require("@oclif/core");
|
|
17
|
-
const
|
|
21
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
18
22
|
const _lodash = require("lodash");
|
|
19
23
|
const _error = require("../../helpers/error");
|
|
20
24
|
const _json = require("../../helpers/json");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
25
|
+
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
26
|
+
const _constisomorphic = require("../shared/const.isomorphic");
|
|
23
27
|
const _helpers = require("../shared/helpers");
|
|
24
28
|
const _helpers1 = require("./helpers");
|
|
25
|
-
const
|
|
29
|
+
const _processorisomorphic = require("./processor.isomorphic");
|
|
26
30
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
31
|
if (typeof WeakMap !== "function") return null;
|
|
28
32
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -31,7 +35,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
31
35
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
36
|
})(nodeInterop);
|
|
33
37
|
}
|
|
34
|
-
function
|
|
38
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
35
39
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
40
|
return obj;
|
|
37
41
|
}
|
|
@@ -44,7 +48,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
44
48
|
if (cache && cache.has(obj)) {
|
|
45
49
|
return cache.get(obj);
|
|
46
50
|
}
|
|
47
|
-
var newObj = {
|
|
51
|
+
var newObj = {
|
|
52
|
+
__proto__: null
|
|
53
|
+
};
|
|
48
54
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
55
|
for(var key in obj){
|
|
50
56
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -82,21 +88,21 @@ const joinExtractedFiles = async (workflowDirCtx, workflowJson)=>{
|
|
|
82
88
|
}).entries()){
|
|
83
89
|
const currJoinedFilePaths = {};
|
|
84
90
|
const prevJoinedFilePaths = joinedFilePathsPerLevel[idx - 1] || {};
|
|
85
|
-
(0,
|
|
91
|
+
(0, _objectisomorphic.mapValuesDeep)(workflowJson, (value, key, parts)=>{
|
|
86
92
|
// If not marked with the @ suffix, there's nothing to do.
|
|
87
|
-
if (!
|
|
88
|
-
const objPathToFieldStr =
|
|
89
|
-
const inlinObjPathStr = objPathToFieldStr.replace(
|
|
93
|
+
if (!_constisomorphic.FILEPATH_MARKED_RE.test(key)) return;
|
|
94
|
+
const objPathToFieldStr = _objectisomorphic.ObjPath.stringify(parts);
|
|
95
|
+
const inlinObjPathStr = objPathToFieldStr.replace(_constisomorphic.FILEPATH_MARKED_RE, "");
|
|
90
96
|
// If there is inlined content present already, then nothing more to do.
|
|
91
97
|
if ((0, _lodash.hasIn)(workflowJson, inlinObjPathStr)) return;
|
|
92
98
|
// Check if the extracted path found at the current field path belongs to
|
|
93
99
|
// a node whose parent or grandparent has been previously joined earlier
|
|
94
100
|
// in the tree. If so, rebase the extracted path to be a relative path to
|
|
95
101
|
// the workflow json.
|
|
96
|
-
const lastFound = (0,
|
|
102
|
+
const lastFound = (0, _objectisomorphic.getLastFound)(prevJoinedFilePaths, parts);
|
|
97
103
|
const prevJoinedFilePath = typeof lastFound === "string" ? lastFound : undefined;
|
|
98
|
-
const rebasedFilePath = prevJoinedFilePath ?
|
|
99
|
-
const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(rebasedFilePath,
|
|
104
|
+
const rebasedFilePath = prevJoinedFilePath ? _nodepath.join(_nodepath.dirname(prevJoinedFilePath), value) : value;
|
|
105
|
+
const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(rebasedFilePath, _nodepath.resolve(workflowDirCtx.abspath, _processorisomorphic.WORKFLOW_JSON), uniqueFilePaths, objPathToFieldStr);
|
|
100
106
|
if (invalidFilePathError) {
|
|
101
107
|
errors.push(invalidFilePathError);
|
|
102
108
|
// Wipe the invalid file path in the node so the final workflow json
|
|
@@ -136,16 +142,16 @@ const joinExtractedFiles = async (workflowDirCtx, workflowJson)=>{
|
|
|
136
142
|
];
|
|
137
143
|
};
|
|
138
144
|
const readWorkflowDir = async (workflowDirCtx, opts = {})=>{
|
|
139
|
-
const { abspath
|
|
140
|
-
const { withExtractedFiles =false
|
|
141
|
-
const dirExists = await
|
|
145
|
+
const { abspath } = workflowDirCtx;
|
|
146
|
+
const { withExtractedFiles = false, withReadonlyField = false } = opts;
|
|
147
|
+
const dirExists = await _fsextra.pathExists(abspath);
|
|
142
148
|
if (!dirExists) throw new Error(`${abspath} does not exist`);
|
|
143
149
|
const workflowJsonPath = await (0, _helpers1.lsWorkflowJson)(abspath);
|
|
144
150
|
if (!workflowJsonPath) throw new Error(`${abspath} is not a workflow directory`);
|
|
145
151
|
const result = await (0, _json.readJson)(workflowJsonPath);
|
|
146
152
|
if (!result[0]) return result;
|
|
147
153
|
let [workflowJson] = result;
|
|
148
|
-
workflowJson = withReadonlyField ? workflowJson : (0,
|
|
154
|
+
workflowJson = withReadonlyField ? workflowJson : (0, _objectisomorphic.omitDeep)(workflowJson, [
|
|
149
155
|
"__readonly"
|
|
150
156
|
]);
|
|
151
157
|
return withExtractedFiles ? joinExtractedFiles(workflowDirCtx, workflowJson) : [
|
|
@@ -163,7 +169,7 @@ const readWorkflowDir = async (workflowDirCtx, opts = {})=>{
|
|
|
163
169
|
// eslint-disable-next-line no-await-in-loop
|
|
164
170
|
const [workflow, readErrors] = await readWorkflowDir(workflowDirCtx, opts);
|
|
165
171
|
if (readErrors.length > 0) {
|
|
166
|
-
const workflowJsonPath =
|
|
172
|
+
const workflowJsonPath = _nodepath.resolve(workflowDirCtx.abspath, _processorisomorphic.WORKFLOW_JSON);
|
|
167
173
|
const e = new _error.SourceError((0, _error.formatErrors)(readErrors), workflowJsonPath);
|
|
168
174
|
errors.push(e);
|
|
169
175
|
continue;
|
|
@@ -179,7 +185,7 @@ const readWorkflowDir = async (workflowDirCtx, opts = {})=>{
|
|
|
179
185
|
];
|
|
180
186
|
};
|
|
181
187
|
const readAllForCommandTarget = async (target, opts = {})=>{
|
|
182
|
-
const { type: targetType
|
|
188
|
+
const { type: targetType, context: targetCtx } = target;
|
|
183
189
|
if (!targetCtx.exists) {
|
|
184
190
|
const subject = targetType === "workflowDir" ? "a workflow directory at" : "workflow directories in";
|
|
185
191
|
return _core.ux.error(`Cannot locate ${subject} \`${targetCtx.abspath}\``);
|
|
@@ -193,11 +199,11 @@ const readAllForCommandTarget = async (target, opts = {})=>{
|
|
|
193
199
|
}
|
|
194
200
|
case "workflowsIndexDir":
|
|
195
201
|
{
|
|
196
|
-
const dirents = await
|
|
202
|
+
const dirents = await _fsextra.readdir(targetCtx.abspath, {
|
|
197
203
|
withFileTypes: true
|
|
198
204
|
});
|
|
199
205
|
const promises = dirents.map(async (dirent)=>{
|
|
200
|
-
const abspath =
|
|
206
|
+
const abspath = _nodepath.resolve(targetCtx.abspath, dirent.name);
|
|
201
207
|
const workflowDirCtx = {
|
|
202
208
|
type: "workflow",
|
|
203
209
|
key: dirent.name,
|
|
@@ -9,18 +9,26 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
pruneWorkflowsIndexDir: function() {
|
|
13
|
+
return pruneWorkflowsIndexDir;
|
|
14
|
+
},
|
|
15
|
+
writeWorkflowDirFromBundle: function() {
|
|
16
|
+
return writeWorkflowDirFromBundle;
|
|
17
|
+
},
|
|
18
|
+
writeWorkflowDirFromData: function() {
|
|
19
|
+
return writeWorkflowDirFromData;
|
|
20
|
+
},
|
|
21
|
+
writeWorkflowsIndexDir: function() {
|
|
22
|
+
return writeWorkflowsIndexDir;
|
|
23
|
+
}
|
|
16
24
|
});
|
|
17
|
-
const
|
|
18
|
-
const
|
|
25
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
26
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
19
27
|
const _lodash = require("lodash");
|
|
20
28
|
const _const = require("../../helpers/const");
|
|
21
29
|
const _json = require("../../helpers/json");
|
|
22
30
|
const _helpers = require("./helpers");
|
|
23
|
-
const
|
|
31
|
+
const _processorisomorphic = require("./processor.isomorphic");
|
|
24
32
|
const _reader = require("./reader");
|
|
25
33
|
function _getRequireWildcardCache(nodeInterop) {
|
|
26
34
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -30,7 +38,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
30
38
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
39
|
})(nodeInterop);
|
|
32
40
|
}
|
|
33
|
-
function
|
|
41
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
42
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
43
|
return obj;
|
|
36
44
|
}
|
|
@@ -43,7 +51,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
43
51
|
if (cache && cache.has(obj)) {
|
|
44
52
|
return cache.get(obj);
|
|
45
53
|
}
|
|
46
|
-
var newObj = {
|
|
54
|
+
var newObj = {
|
|
55
|
+
__proto__: null
|
|
56
|
+
};
|
|
47
57
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
58
|
for(var key in obj){
|
|
49
59
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -67,36 +77,36 @@ const writeWorkflowDirFromData = async (workflowDirCtx, remoteWorkflow)=>{
|
|
|
67
77
|
const [localWorkflow] = workflowDirCtx.exists ? await (0, _reader.readWorkflowDir)(workflowDirCtx, {
|
|
68
78
|
withExtractedFiles: true
|
|
69
79
|
}) : [];
|
|
70
|
-
const bundle = (0,
|
|
80
|
+
const bundle = (0, _processorisomorphic.buildWorkflowDirBundle)(remoteWorkflow, localWorkflow);
|
|
71
81
|
return writeWorkflowDirFromBundle(workflowDirCtx, bundle);
|
|
72
82
|
};
|
|
73
83
|
const writeWorkflowDirFromBundle = async (workflowDirCtx, workflowDirBundle)=>{
|
|
74
|
-
const backupDirPath =
|
|
84
|
+
const backupDirPath = _nodepath.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
|
|
75
85
|
try {
|
|
76
86
|
if (workflowDirCtx.exists) {
|
|
77
|
-
await
|
|
78
|
-
await
|
|
87
|
+
await _fsextra.copy(workflowDirCtx.abspath, backupDirPath);
|
|
88
|
+
await _fsextra.emptyDir(workflowDirCtx.abspath);
|
|
79
89
|
}
|
|
80
90
|
const promises = Object.entries(workflowDirBundle).map(([relpath, fileContent])=>{
|
|
81
|
-
const filePath =
|
|
82
|
-
return relpath ===
|
|
91
|
+
const filePath = _nodepath.resolve(workflowDirCtx.abspath, relpath);
|
|
92
|
+
return relpath === _processorisomorphic.WORKFLOW_JSON ? _fsextra.outputJson(filePath, fileContent, {
|
|
83
93
|
spaces: _json.DOUBLE_SPACES
|
|
84
|
-
}) :
|
|
94
|
+
}) : _fsextra.outputFile(filePath, fileContent);
|
|
85
95
|
});
|
|
86
96
|
await Promise.all(promises);
|
|
87
97
|
} catch (error) {
|
|
88
98
|
// In case of any error, wipe the target directory that is likely in a bad
|
|
89
99
|
// state then restore the backup if one existed before.
|
|
90
100
|
if (workflowDirCtx.exists) {
|
|
91
|
-
await
|
|
92
|
-
await
|
|
101
|
+
await _fsextra.emptyDir(workflowDirCtx.abspath);
|
|
102
|
+
await _fsextra.copy(backupDirPath, workflowDirCtx.abspath);
|
|
93
103
|
} else {
|
|
94
|
-
await
|
|
104
|
+
await _fsextra.remove(workflowDirCtx.abspath);
|
|
95
105
|
}
|
|
96
106
|
throw error;
|
|
97
107
|
} finally{
|
|
98
108
|
// Always clean up the backup directory in the temp sandbox.
|
|
99
|
-
await
|
|
109
|
+
await _fsextra.remove(backupDirPath);
|
|
100
110
|
}
|
|
101
111
|
};
|
|
102
112
|
/*
|
|
@@ -109,31 +119,31 @@ const writeWorkflowDirFromBundle = async (workflowDirCtx, workflowDirBundle)=>{
|
|
|
109
119
|
w.key.toLowerCase(),
|
|
110
120
|
w
|
|
111
121
|
]));
|
|
112
|
-
const dirents = await
|
|
122
|
+
const dirents = await _fsextra.readdir(indexDirCtx.abspath, {
|
|
113
123
|
withFileTypes: true
|
|
114
124
|
});
|
|
115
125
|
const promises = dirents.map(async (dirent)=>{
|
|
116
126
|
const direntName = dirent.name.toLowerCase();
|
|
117
|
-
const direntPath =
|
|
127
|
+
const direntPath = _nodepath.resolve(indexDirCtx.abspath, direntName);
|
|
118
128
|
if (await (0, _helpers.isWorkflowDir)(direntPath) && workflowsByKey[direntName]) {
|
|
119
129
|
return;
|
|
120
130
|
}
|
|
121
|
-
await
|
|
131
|
+
await _fsextra.remove(direntPath);
|
|
122
132
|
});
|
|
123
133
|
await Promise.all(promises);
|
|
124
134
|
};
|
|
125
135
|
const writeWorkflowsIndexDir = async (indexDirCtx, remoteWorkflows)=>{
|
|
126
|
-
const backupDirPath =
|
|
136
|
+
const backupDirPath = _nodepath.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
|
|
127
137
|
try {
|
|
128
138
|
// If the index directory already exists, back it up in the temp sandbox
|
|
129
139
|
// before wiping it clean.
|
|
130
140
|
if (indexDirCtx.exists) {
|
|
131
|
-
await
|
|
141
|
+
await _fsextra.copy(indexDirCtx.abspath, backupDirPath);
|
|
132
142
|
await pruneWorkflowsIndexDir(indexDirCtx, remoteWorkflows);
|
|
133
143
|
}
|
|
134
144
|
// Write given remote workflows into the given workflows directory path.
|
|
135
145
|
const writeWorkflowDirPromises = remoteWorkflows.map(async (workflow)=>{
|
|
136
|
-
const workflowDirPath =
|
|
146
|
+
const workflowDirPath = _nodepath.resolve(indexDirCtx.abspath, workflow.key);
|
|
137
147
|
const workflowDirCtx = {
|
|
138
148
|
type: "workflow",
|
|
139
149
|
key: workflow.key,
|
|
@@ -147,14 +157,14 @@ const writeWorkflowsIndexDir = async (indexDirCtx, remoteWorkflows)=>{
|
|
|
147
157
|
// In case of any error, wipe the index directory that is likely in a bad
|
|
148
158
|
// state then restore the backup if one existed before.
|
|
149
159
|
if (indexDirCtx.exists) {
|
|
150
|
-
await
|
|
151
|
-
await
|
|
160
|
+
await _fsextra.emptyDir(indexDirCtx.abspath);
|
|
161
|
+
await _fsextra.copy(backupDirPath, indexDirCtx.abspath);
|
|
152
162
|
} else {
|
|
153
|
-
await
|
|
163
|
+
await _fsextra.remove(indexDirCtx.abspath);
|
|
154
164
|
}
|
|
155
165
|
throw error;
|
|
156
166
|
} finally{
|
|
157
167
|
// Always clean up the backup directory in the temp sandbox.
|
|
158
|
-
await
|
|
168
|
+
await _fsextra.remove(backupDirPath);
|
|
159
169
|
}
|
|
160
170
|
};
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ensureResourceDirForTarget", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ensureResourceDirForTarget;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@oclif/core");
|
|
10
12
|
const ensureResourceDirForTarget = (resourceDirCtx, target)=>{
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "load", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _loader.load;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
_export_star(require("./helpers"), exports);
|
|
12
|
+
const _loader = require("./loader");
|
|
13
|
+
_export_star(require("./types"), exports);
|
|
14
|
+
function _export_star(from, to) {
|
|
15
|
+
Object.keys(from).forEach(function(k) {
|
|
16
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
17
|
+
Object.defineProperty(to, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return from[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return from;
|
|
26
|
+
}
|
|
@@ -8,12 +8,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
});
|
|
9
9
|
Object.defineProperty(exports, "load", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: ()
|
|
11
|
+
get: function() {
|
|
12
|
+
return load;
|
|
13
|
+
}
|
|
12
14
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const _translation = /*#__PURE__*/
|
|
16
|
-
const _workflow = /*#__PURE__*/
|
|
15
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
16
|
+
const _emaillayout = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/email-layout"));
|
|
17
|
+
const _translation = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/translation"));
|
|
18
|
+
const _workflow = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/workflow"));
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) {
|
|
18
20
|
if (typeof WeakMap !== "function") return null;
|
|
19
21
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -22,7 +24,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
22
24
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
25
|
})(nodeInterop);
|
|
24
26
|
}
|
|
25
|
-
function
|
|
27
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
28
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
29
|
return obj;
|
|
28
30
|
}
|
|
@@ -35,7 +37,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
35
37
|
if (cache && cache.has(obj)) {
|
|
36
38
|
return cache.get(obj);
|
|
37
39
|
}
|
|
38
|
-
var newObj = {
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
39
43
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
44
|
for(var key in obj){
|
|
41
45
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -59,17 +63,17 @@ const evaluateRecursively = async (ctx, currDir)=>{
|
|
|
59
63
|
if (!ctx.resourceDir && isWorkflowDir) {
|
|
60
64
|
ctx.resourceDir = {
|
|
61
65
|
type: "workflow",
|
|
62
|
-
key:
|
|
66
|
+
key: _nodepath.basename(currDir),
|
|
63
67
|
abspath: currDir,
|
|
64
68
|
exists: true
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
// Check if we are inside a layout directory, and if so update the context.
|
|
68
|
-
const isEmailLayoutDir = await
|
|
72
|
+
const isEmailLayoutDir = await _emaillayout.isEmailLayoutDir(currDir);
|
|
69
73
|
if (!ctx.resourceDir && isEmailLayoutDir) {
|
|
70
74
|
ctx.resourceDir = {
|
|
71
75
|
type: "email_layout",
|
|
72
|
-
key:
|
|
76
|
+
key: _nodepath.basename(currDir),
|
|
73
77
|
abspath: currDir,
|
|
74
78
|
exists: true
|
|
75
79
|
};
|
|
@@ -81,7 +85,7 @@ const evaluateRecursively = async (ctx, currDir)=>{
|
|
|
81
85
|
if (!ctx.resourceDir && isTranslationDir) {
|
|
82
86
|
ctx.resourceDir = {
|
|
83
87
|
type: "translation",
|
|
84
|
-
key:
|
|
88
|
+
key: _nodepath.basename(currDir),
|
|
85
89
|
abspath: currDir,
|
|
86
90
|
exists: true
|
|
87
91
|
};
|
|
@@ -91,9 +95,9 @@ const evaluateRecursively = async (ctx, currDir)=>{
|
|
|
91
95
|
// we can use to (semi-)explicitly figure out the project directory structure.
|
|
92
96
|
if (ctx.resourceDir) return ctx;
|
|
93
97
|
// If we reached the root of the filesystem, nothing more to do.
|
|
94
|
-
const { root
|
|
98
|
+
const { root } = _nodepath.parse(currDir);
|
|
95
99
|
if (currDir === root) return ctx;
|
|
96
|
-
const parentDir =
|
|
100
|
+
const parentDir = _nodepath.resolve(currDir, "..");
|
|
97
101
|
return evaluateRecursively(ctx, parentDir);
|
|
98
102
|
};
|
|
99
103
|
const load = async (commandId)=>{
|
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
Object.defineProperty(exports, "default", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: ()
|
|
9
|
+
get: function() {
|
|
10
|
+
return _default;
|
|
11
|
+
}
|
|
10
12
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const _yup = /*#__PURE__*/
|
|
13
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
14
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
15
|
+
const _yup = /*#__PURE__*/ _interop_require_wildcard(require("yup"));
|
|
14
16
|
const _const = require("./helpers/const");
|
|
15
17
|
function _getRequireWildcardCache(nodeInterop) {
|
|
16
18
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -20,7 +22,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
20
22
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
23
|
})(nodeInterop);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
25
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
24
26
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
27
|
return obj;
|
|
26
28
|
}
|
|
@@ -33,7 +35,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
33
35
|
if (cache && cache.has(obj)) {
|
|
34
36
|
return cache.get(obj);
|
|
35
37
|
}
|
|
36
|
-
var newObj = {
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
37
41
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
42
|
for(var key in obj){
|
|
39
43
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -59,10 +63,10 @@ let USER_CONFIG;
|
|
|
59
63
|
const maybeReadJsonConfig = async (configDir)=>{
|
|
60
64
|
// Don't use a user config file in tests.
|
|
61
65
|
if (_const.isTestEnv) return null;
|
|
62
|
-
const pathToJsonConfig =
|
|
63
|
-
const exists = await
|
|
66
|
+
const pathToJsonConfig = _nodepath.resolve(configDir, "config.json");
|
|
67
|
+
const exists = await _fsextra.pathExists(pathToJsonConfig);
|
|
64
68
|
if (!exists) return null;
|
|
65
|
-
return
|
|
69
|
+
return _fsextra.readJSON(pathToJsonConfig);
|
|
66
70
|
};
|
|
67
71
|
const load = async (configDir)=>{
|
|
68
72
|
const readConfig = await maybeReadJsonConfig(configDir);
|