@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.
Files changed (90) hide show
  1. package/README.md +68 -531
  2. package/bin/dev.js +6 -0
  3. package/bin/run.js +7 -0
  4. package/dist/{commands → src/commands}/commit/get.js +24 -9
  5. package/dist/{commands → src/commands}/commit/index.js +23 -8
  6. package/dist/{commands → src/commands}/commit/list.js +29 -14
  7. package/dist/{commands → src/commands}/commit/promote.js +26 -11
  8. package/dist/{commands → src/commands}/knock.js +21 -6
  9. package/dist/{commands → src/commands}/layout/get.js +28 -13
  10. package/dist/{commands → src/commands}/layout/list.js +29 -14
  11. package/dist/{commands → src/commands}/layout/pull.js +47 -30
  12. package/dist/{commands → src/commands}/layout/push.js +38 -21
  13. package/dist/{commands → src/commands}/layout/validate.js +33 -16
  14. package/dist/src/commands/ping.js +37 -0
  15. package/dist/{commands → src/commands}/translation/get.js +33 -16
  16. package/dist/{commands → src/commands}/translation/list.js +34 -17
  17. package/dist/{commands → src/commands}/translation/pull.js +36 -19
  18. package/dist/{commands → src/commands}/translation/push.js +33 -15
  19. package/dist/{commands → src/commands}/translation/validate.js +30 -13
  20. package/dist/{commands → src/commands}/whoami.js +22 -7
  21. package/dist/{commands → src/commands}/workflow/activate.js +27 -12
  22. package/dist/{commands → src/commands}/workflow/get.js +35 -18
  23. package/dist/{commands → src/commands}/workflow/list.js +34 -17
  24. package/dist/{commands → src/commands}/workflow/new.js +37 -20
  25. package/dist/{commands → src/commands}/workflow/pull.js +44 -27
  26. package/dist/{commands → src/commands}/workflow/push.js +34 -17
  27. package/dist/{commands → src/commands}/workflow/run.js +25 -10
  28. package/dist/{commands → src/commands}/workflow/validate.js +30 -13
  29. package/dist/{index.js → src/index.js} +3 -1
  30. package/dist/{isomorphic.js → src/isomorphic.js} +8 -4
  31. package/dist/{lib → src/lib}/api-v1.js +57 -41
  32. package/dist/{lib → src/lib}/base-command.js +38 -15
  33. package/dist/{lib → src/lib}/helpers/const.js +18 -10
  34. package/dist/{lib → src/lib}/helpers/date.js +9 -5
  35. package/dist/{lib → src/lib}/helpers/error.js +42 -8
  36. package/dist/{lib → src/lib}/helpers/flag.js +24 -12
  37. package/dist/{lib → src/lib}/helpers/fs.js +10 -6
  38. package/dist/{lib → src/lib}/helpers/json.js +19 -9
  39. package/dist/{lib → src/lib}/helpers/liquid.js +3 -1
  40. package/dist/{lib → src/lib}/helpers/object.isomorphic.js +35 -7
  41. package/dist/{lib → src/lib}/helpers/page.js +34 -18
  42. package/dist/{lib → src/lib}/helpers/request.js +12 -6
  43. package/dist/{lib → src/lib}/helpers/string.js +8 -4
  44. package/dist/{lib → src/lib}/helpers/ux.js +9 -5
  45. package/dist/{lib → src/lib}/marshal/commit/helpers.js +3 -1
  46. package/dist/src/lib/marshal/commit/index.js +19 -0
  47. package/dist/{lib → src/lib}/marshal/conditions/helpers.js +5 -3
  48. package/dist/src/lib/marshal/conditions/index.js +19 -0
  49. package/dist/{lib → src/lib}/marshal/email-layout/helpers.js +25 -15
  50. package/dist/src/lib/marshal/email-layout/index.js +22 -0
  51. package/dist/{lib → src/lib}/marshal/email-layout/processor.isomorphic.js +17 -11
  52. package/dist/{lib → src/lib}/marshal/email-layout/reader.js +29 -23
  53. package/dist/{lib → src/lib}/marshal/email-layout/writer.js +38 -30
  54. package/dist/src/lib/marshal/index.isomorphic.js +26 -0
  55. package/dist/{lib → src/lib}/marshal/shared/const.isomorphic.js +6 -2
  56. package/dist/{lib → src/lib}/marshal/shared/helpers.js +22 -14
  57. package/dist/{lib → src/lib}/marshal/translation/helpers.js +52 -30
  58. package/dist/src/lib/marshal/translation/index.js +22 -0
  59. package/dist/{lib → src/lib}/marshal/translation/processor.isomorphic.js +9 -3
  60. package/dist/{lib → src/lib}/marshal/translation/reader.js +14 -10
  61. package/dist/{lib → src/lib}/marshal/translation/writer.js +21 -15
  62. package/dist/{lib → src/lib}/marshal/workflow/generator.js +23 -15
  63. package/dist/{lib → src/lib}/marshal/workflow/helpers.js +47 -27
  64. package/dist/src/lib/marshal/workflow/index.js +23 -0
  65. package/dist/{lib → src/lib}/marshal/workflow/processor.isomorphic.js +35 -23
  66. package/dist/{lib → src/lib}/marshal/workflow/reader.js +30 -24
  67. package/dist/{lib → src/lib}/marshal/workflow/types.js +3 -1
  68. package/dist/{lib → src/lib}/marshal/workflow/writer.js +40 -30
  69. package/dist/{lib → src/lib}/run-context/helpers.js +3 -1
  70. package/dist/src/lib/run-context/index.js +26 -0
  71. package/dist/{lib → src/lib}/run-context/loader.js +17 -13
  72. package/dist/{lib → src/lib}/user-config.js +13 -9
  73. package/oclif.manifest.json +2 -1386
  74. package/package.json +16 -16
  75. package/bin/dev +0 -17
  76. package/bin/run +0 -5
  77. package/dist/commands/ping.js +0 -22
  78. package/dist/lib/marshal/commit/index.js +0 -17
  79. package/dist/lib/marshal/conditions/index.js +0 -17
  80. package/dist/lib/marshal/email-layout/index.js +0 -20
  81. package/dist/lib/marshal/index.isomorphic.js +0 -20
  82. package/dist/lib/marshal/translation/index.js +0 -20
  83. package/dist/lib/marshal/workflow/index.js +0 -21
  84. package/dist/lib/run-context/index.js +0 -22
  85. /package/dist/{lib → src/lib}/marshal/commit/types.js +0 -0
  86. /package/dist/{lib → src/lib}/marshal/conditions/types.js +0 -0
  87. /package/dist/{lib → src/lib}/marshal/email-layout/types.js +0 -0
  88. /package/dist/{lib → src/lib}/marshal/shared/types.js +0 -0
  89. /package/dist/{lib → src/lib}/marshal/translation/types.js +0 -0
  90. /package/dist/{lib → src/lib}/run-context/types.js +0 -0
@@ -9,21 +9,25 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- readAllForCommandTarget: ()=>readAllForCommandTarget,
13
- readEmailLayoutDir: ()=>readEmailLayoutDir
12
+ readAllForCommandTarget: function() {
13
+ return readAllForCommandTarget;
14
+ },
15
+ readEmailLayoutDir: function() {
16
+ return readEmailLayoutDir;
17
+ }
14
18
  });
15
- const _nodePath = /*#__PURE__*/ _interopRequireDefault(require("node:path"));
19
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
16
20
  const _core = require("@oclif/core");
17
- const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
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 _objectIsomorphic = require("../../helpers/object.isomorphic");
22
- const _constIsomorphic = require("../shared/const.isomorphic");
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 _processorIsomorphic = require("./processor.isomorphic");
26
- function _interopRequireDefault(obj) {
29
+ const _processorisomorphic = require("./processor.isomorphic");
30
+ function _interop_require_default(obj) {
27
31
  return obj && obj.__esModule ? obj : {
28
32
  default: obj
29
33
  };
@@ -36,7 +40,7 @@ function _getRequireWildcardCache(nodeInterop) {
36
40
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
37
41
  })(nodeInterop);
38
42
  }
39
- function _interopRequireWildcard(obj, nodeInterop) {
43
+ function _interop_require_wildcard(obj, nodeInterop) {
40
44
  if (!nodeInterop && obj && obj.__esModule) {
41
45
  return obj;
42
46
  }
@@ -49,7 +53,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
49
53
  if (cache && cache.has(obj)) {
50
54
  return cache.get(obj);
51
55
  }
52
- var newObj = {};
56
+ var newObj = {
57
+ __proto__: null
58
+ };
53
59
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
60
  for(var key in obj){
55
61
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -68,7 +74,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
68
74
  return newObj;
69
75
  }
70
76
  const readAllForCommandTarget = async (target, opts = {})=>{
71
- const { type: targetType , context: targetCtx } = target;
77
+ const { type: targetType, context: targetCtx } = target;
72
78
  if (!targetCtx.exists) {
73
79
  const subject = targetType === "emailLayoutDir" ? "a layout directory at" : "layout directories in";
74
80
  return _core.ux.error(`Cannot locate ${subject} \`${targetCtx.abspath}\``);
@@ -82,11 +88,11 @@ const readAllForCommandTarget = async (target, opts = {})=>{
82
88
  }
83
89
  case "emailLayoutsIndexDir":
84
90
  {
85
- const dirents = await _fsExtra.readdir(targetCtx.abspath, {
91
+ const dirents = await _fsextra.readdir(targetCtx.abspath, {
86
92
  withFileTypes: true
87
93
  });
88
94
  const promises = dirents.map(async (dirent)=>{
89
- const abspath = _nodePath.default.resolve(targetCtx.abspath, dirent.name);
95
+ const abspath = _nodepath.default.resolve(targetCtx.abspath, dirent.name);
90
96
  const layoutDirCtx = {
91
97
  type: "email_layout",
92
98
  key: dirent.name,
@@ -112,7 +118,7 @@ const readAllForCommandTarget = async (target, opts = {})=>{
112
118
  // eslint-disable-next-line no-await-in-loop
113
119
  const [layout, readErrors] = await readEmailLayoutDir(layoutDirCtx, opts);
114
120
  if (readErrors.length > 0) {
115
- const layoutJsonPath = _nodePath.default.resolve(layoutDirCtx.abspath, _processorIsomorphic.LAYOUT_JSON);
121
+ const layoutJsonPath = _nodepath.default.resolve(layoutDirCtx.abspath, _processorisomorphic.LAYOUT_JSON);
116
122
  const e = new _error.SourceError((0, _error.formatErrors)(readErrors), layoutJsonPath);
117
123
  errors.push(e);
118
124
  continue;
@@ -128,16 +134,16 @@ const readAllForCommandTarget = async (target, opts = {})=>{
128
134
  ];
129
135
  };
130
136
  const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
131
- const { abspath } = layoutDirCtx;
132
- const { withExtractedFiles =false , withReadonlyField =false } = opts;
133
- const dirExists = await _fsExtra.pathExists(abspath);
137
+ const { abspath } = layoutDirCtx;
138
+ const { withExtractedFiles = false, withReadonlyField = false } = opts;
139
+ const dirExists = await _fsextra.pathExists(abspath);
134
140
  if (!dirExists) throw new Error(`${abspath} does not exist`);
135
141
  const layoutJsonPath = await (0, _helpers1.lsEmailLayoutJson)(abspath);
136
142
  if (!layoutJsonPath) throw new Error(`${abspath} is not a layout directory`);
137
143
  const result = await (0, _json.readJson)(layoutJsonPath);
138
144
  if (!result[0]) return result;
139
145
  let [layoutJson] = result;
140
- layoutJson = withReadonlyField ? layoutJson : (0, _objectIsomorphic.omitDeep)(layoutJson, [
146
+ layoutJson = withReadonlyField ? layoutJson : (0, _objectisomorphic.omitDeep)(layoutJson, [
141
147
  "__readonly"
142
148
  ]);
143
149
  return withExtractedFiles ? joinExtractedFiles(layoutDirCtx, layoutJson) : [
@@ -155,15 +161,15 @@ const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
155
161
  // layout.json) in the layout json node. Mutated in place, and used
156
162
  // to validate the uniqueness of an extracted path encountered.
157
163
  const uniqueFilePaths = {};
158
- (0, _objectIsomorphic.mapValuesDeep)(layoutJson, (relpath, key, parts)=>{
164
+ (0, _objectisomorphic.mapValuesDeep)(layoutJson, (relpath, key, parts)=>{
159
165
  // If not marked with the @suffix, there's nothing to do.
160
- if (!_constIsomorphic.FILEPATH_MARKED_RE.test(key)) return;
161
- const objPathToFieldStr = _objectIsomorphic.ObjPath.stringify(parts);
162
- const inlinObjPathStr = objPathToFieldStr.replace(_constIsomorphic.FILEPATH_MARKED_RE, "");
166
+ if (!_constisomorphic.FILEPATH_MARKED_RE.test(key)) return;
167
+ const objPathToFieldStr = _objectisomorphic.ObjPath.stringify(parts);
168
+ const inlinObjPathStr = objPathToFieldStr.replace(_constisomorphic.FILEPATH_MARKED_RE, "");
163
169
  // If there is inlined content present already, then nothing more to do.
164
170
  if ((0, _lodash.hasIn)(layoutJson, inlinObjPathStr)) return;
165
171
  // Check if the extracted path found at the current field path is valid
166
- const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(relpath, _nodePath.default.resolve(layoutDirCtx.abspath, _processorIsomorphic.LAYOUT_JSON), uniqueFilePaths, objPathToFieldStr);
172
+ const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(relpath, _nodepath.default.resolve(layoutDirCtx.abspath, _processorisomorphic.LAYOUT_JSON), uniqueFilePaths, objPathToFieldStr);
167
173
  if (invalidFilePathError) {
168
174
  errors.push(invalidFilePathError);
169
175
  // Wipe the invalid file path in the node so the final layout json
@@ -9,19 +9,25 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- writeEmailLayoutDirFromData: ()=>writeEmailLayoutDirFromData,
13
- writeEmailLayoutIndexDir: ()=>writeEmailLayoutIndexDir,
14
- pruneLayoutsIndexDir: ()=>pruneLayoutsIndexDir
12
+ pruneLayoutsIndexDir: function() {
13
+ return pruneLayoutsIndexDir;
14
+ },
15
+ writeEmailLayoutDirFromData: function() {
16
+ return writeEmailLayoutDirFromData;
17
+ },
18
+ writeEmailLayoutIndexDir: function() {
19
+ return writeEmailLayoutIndexDir;
20
+ }
15
21
  });
16
- const _nodePath = /*#__PURE__*/ _interopRequireDefault(require("node:path"));
17
- const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
22
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
23
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
18
24
  const _lodash = require("lodash");
19
25
  const _const = require("../../helpers/const");
20
26
  const _json = require("../../helpers/json");
21
27
  const _helpers = require("./helpers");
22
- const _processorIsomorphic = require("./processor.isomorphic");
28
+ const _processorisomorphic = require("./processor.isomorphic");
23
29
  const _reader = require("./reader");
24
- function _interopRequireDefault(obj) {
30
+ function _interop_require_default(obj) {
25
31
  return obj && obj.__esModule ? obj : {
26
32
  default: obj
27
33
  };
@@ -34,7 +40,7 @@ function _getRequireWildcardCache(nodeInterop) {
34
40
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
35
41
  })(nodeInterop);
36
42
  }
37
- function _interopRequireWildcard(obj, nodeInterop) {
43
+ function _interop_require_wildcard(obj, nodeInterop) {
38
44
  if (!nodeInterop && obj && obj.__esModule) {
39
45
  return obj;
40
46
  }
@@ -47,7 +53,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
47
53
  if (cache && cache.has(obj)) {
48
54
  return cache.get(obj);
49
55
  }
50
- var newObj = {};
56
+ var newObj = {
57
+ __proto__: null
58
+ };
51
59
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
52
60
  for(var key in obj){
53
61
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -71,45 +79,45 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
71
79
  const [localEmailLayout] = emailLayoutDirCtx.exists ? await (0, _reader.readEmailLayoutDir)(emailLayoutDirCtx, {
72
80
  withExtractedFiles: true
73
81
  }) : [];
74
- const bundle = (0, _processorIsomorphic.buildEmailLayoutDirBundle)(remoteEmailLayout, localEmailLayout);
75
- const backupDirPath = _nodePath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
82
+ const bundle = (0, _processorisomorphic.buildEmailLayoutDirBundle)(remoteEmailLayout, localEmailLayout);
83
+ const backupDirPath = _nodepath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
76
84
  try {
77
85
  // We store a backup in case there's an error.
78
86
  if (emailLayoutDirCtx.exists) {
79
- await _fsExtra.copy(emailLayoutDirCtx.abspath, backupDirPath);
80
- await _fsExtra.emptyDir(emailLayoutDirCtx.abspath);
87
+ await _fsextra.copy(emailLayoutDirCtx.abspath, backupDirPath);
88
+ await _fsextra.emptyDir(emailLayoutDirCtx.abspath);
81
89
  }
82
90
  const promises = Object.entries(bundle).map(([relpath, fileContent])=>{
83
- const filePath = _nodePath.default.resolve(emailLayoutDirCtx.abspath, relpath);
84
- return relpath === _processorIsomorphic.LAYOUT_JSON ? _fsExtra.outputJson(filePath, fileContent, {
91
+ const filePath = _nodepath.default.resolve(emailLayoutDirCtx.abspath, relpath);
92
+ return relpath === _processorisomorphic.LAYOUT_JSON ? _fsextra.outputJson(filePath, fileContent, {
85
93
  spaces: _json.DOUBLE_SPACES
86
- }) : _fsExtra.outputFile(filePath, fileContent);
94
+ }) : _fsextra.outputFile(filePath, fileContent);
87
95
  });
88
96
  await Promise.all(promises);
89
97
  } catch (error) {
90
98
  // In case of any error, wipe the target directory that is likely in a bad
91
99
  // state then restore the backup if one existed before.
92
100
  if (emailLayoutDirCtx.exists) {
93
- await _fsExtra.emptyDir(emailLayoutDirCtx.abspath);
94
- await _fsExtra.copy(backupDirPath, emailLayoutDirCtx.abspath);
101
+ await _fsextra.emptyDir(emailLayoutDirCtx.abspath);
102
+ await _fsextra.copy(backupDirPath, emailLayoutDirCtx.abspath);
95
103
  } else {
96
- await _fsExtra.remove(emailLayoutDirCtx.abspath);
104
+ await _fsextra.remove(emailLayoutDirCtx.abspath);
97
105
  }
98
106
  throw error;
99
107
  } finally{
100
108
  // Always clean up the backup directory in the temp sandbox.
101
- await _fsExtra.remove(backupDirPath);
109
+ await _fsextra.remove(backupDirPath);
102
110
  }
103
111
  };
104
112
  const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
105
- const backupDirPath = _nodePath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
113
+ const backupDirPath = _nodepath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
106
114
  try {
107
115
  if (indexDirCtx.exists) {
108
- await _fsExtra.copy(indexDirCtx.abspath, backupDirPath);
116
+ await _fsextra.copy(indexDirCtx.abspath, backupDirPath);
109
117
  await pruneLayoutsIndexDir(indexDirCtx, remoteEmailLayouts);
110
118
  }
111
119
  const writeEmailLayoutDirPromises = remoteEmailLayouts.map(async (remoteEmailLayout)=>{
112
- const emailLayoutDirPath = _nodePath.default.resolve(indexDirCtx.abspath, remoteEmailLayout.key);
120
+ const emailLayoutDirPath = _nodepath.default.resolve(indexDirCtx.abspath, remoteEmailLayout.key);
113
121
  const emailLayoutDirCtx = {
114
122
  type: "email_layout",
115
123
  key: remoteEmailLayout.key,
@@ -121,15 +129,15 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
121
129
  await Promise.all(writeEmailLayoutDirPromises);
122
130
  } catch (error) {
123
131
  if (indexDirCtx.exists) {
124
- await _fsExtra.emptyDir(indexDirCtx.abspath);
125
- await _fsExtra.copy(backupDirPath, indexDirCtx.abspath);
132
+ await _fsextra.emptyDir(indexDirCtx.abspath);
133
+ await _fsextra.copy(backupDirPath, indexDirCtx.abspath);
126
134
  } else {
127
- await _fsExtra.remove(indexDirCtx.abspath);
135
+ await _fsextra.remove(indexDirCtx.abspath);
128
136
  }
129
137
  throw error;
130
138
  } finally{
131
139
  // Always clean up the backup directory in the temp sandbox.
132
- await _fsExtra.remove(backupDirPath);
140
+ await _fsextra.remove(backupDirPath);
133
141
  }
134
142
  };
135
143
  /*
@@ -142,16 +150,16 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
142
150
  e.key.toLowerCase(),
143
151
  e
144
152
  ]));
145
- const dirents = await _fsExtra.readdir(indexDirCtx.abspath, {
153
+ const dirents = await _fsextra.readdir(indexDirCtx.abspath, {
146
154
  withFileTypes: true
147
155
  });
148
156
  const promises = dirents.map(async (dirent)=>{
149
157
  const direntName = dirent.name.toLowerCase();
150
- const direntPath = _nodePath.default.resolve(indexDirCtx.abspath, direntName);
158
+ const direntPath = _nodepath.default.resolve(indexDirCtx.abspath, direntName);
151
159
  if (await (0, _helpers.isEmailLayoutDir)(direntPath) && emailLayoutsByKey[direntName]) {
152
160
  return;
153
161
  }
154
- await _fsExtra.remove(direntPath);
162
+ await _fsextra.remove(direntPath);
155
163
  });
156
164
  await Promise.all(promises);
157
165
  };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * IMPORTANT: You must only expose exports from isomorphic modules.
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ function _export(target, all) {
8
+ for(var name in all)Object.defineProperty(target, name, {
9
+ enumerable: true,
10
+ get: all[name]
11
+ });
12
+ }
13
+ _export(exports, {
14
+ buildEmailLayoutDirBundle: function() {
15
+ return _processorisomorphic.buildEmailLayoutDirBundle;
16
+ },
17
+ buildTranslationDirBundle: function() {
18
+ return _processorisomorphic1.buildTranslationDirBundle;
19
+ },
20
+ buildWorkflowDirBundle: function() {
21
+ return _processorisomorphic2.buildWorkflowDirBundle;
22
+ }
23
+ });
24
+ const _processorisomorphic = require("./email-layout/processor.isomorphic");
25
+ const _processorisomorphic1 = require("./translation/processor.isomorphic");
26
+ const _processorisomorphic2 = require("./workflow/processor.isomorphic");
@@ -18,8 +18,12 @@ function _export(target, all) {
18
18
  });
19
19
  }
20
20
  _export(exports, {
21
- FILEPATH_MARKER: ()=>FILEPATH_MARKER,
22
- FILEPATH_MARKED_RE: ()=>FILEPATH_MARKED_RE
21
+ FILEPATH_MARKED_RE: function() {
22
+ return FILEPATH_MARKED_RE;
23
+ },
24
+ FILEPATH_MARKER: function() {
25
+ return FILEPATH_MARKER;
26
+ }
23
27
  });
24
28
  const FILEPATH_MARKER = "@";
25
29
  const FILEPATH_MARKED_RE = new RegExp(`${FILEPATH_MARKER}$`);
@@ -9,12 +9,18 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- readExtractedFileSync: ()=>readExtractedFileSync,
13
- validateExtractedFilePath: ()=>validateExtractedFilePath,
14
- checkIfValidExtractedFilePathFormat: ()=>checkIfValidExtractedFilePathFormat
12
+ checkIfValidExtractedFilePathFormat: function() {
13
+ return checkIfValidExtractedFilePathFormat;
14
+ },
15
+ readExtractedFileSync: function() {
16
+ return readExtractedFileSync;
17
+ },
18
+ validateExtractedFilePath: function() {
19
+ return validateExtractedFilePath;
20
+ }
15
21
  });
16
- const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
17
- const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
22
+ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
23
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
18
24
  const _error = require("../../helpers/error");
19
25
  const _json = require("../../helpers/json");
20
26
  const _liquid = require("../../helpers/liquid");
@@ -27,7 +33,7 @@ function _getRequireWildcardCache(nodeInterop) {
27
33
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
28
34
  })(nodeInterop);
29
35
  }
30
- function _interopRequireWildcard(obj, nodeInterop) {
36
+ function _interop_require_wildcard(obj, nodeInterop) {
31
37
  if (!nodeInterop && obj && obj.__esModule) {
32
38
  return obj;
33
39
  }
@@ -40,7 +46,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
40
46
  if (cache && cache.has(obj)) {
41
47
  return cache.get(obj);
42
48
  }
43
- var newObj = {};
49
+ var newObj = {
50
+ __proto__: null
51
+ };
44
52
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
45
53
  for(var key in obj){
46
54
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -65,8 +73,8 @@ const DECODABLE_JSON_FILES = new Set([
65
73
  ]);
66
74
  const readExtractedFileSync = (relpath, dirCtx, objPathToFieldStr = "")=>{
67
75
  // Check if the file actually exists at the given file path.
68
- const abspath = _nodePath.resolve(dirCtx.abspath, relpath);
69
- const exists = _fsExtra.pathExistsSync(abspath);
76
+ const abspath = _nodepath.resolve(dirCtx.abspath, relpath);
77
+ const exists = _fsextra.pathExistsSync(abspath);
70
78
  if (!exists) {
71
79
  const error = new _error.JsonDataError("must be a relative path string to a file that exists", objPathToFieldStr);
72
80
  return [
@@ -76,7 +84,7 @@ const readExtractedFileSync = (relpath, dirCtx, objPathToFieldStr = "")=>{
76
84
  }
77
85
  // Read the file and check for valid liquid syntax given it is supported
78
86
  // across all message templates and file extensions.
79
- const contentStr = _fsExtra.readFileSync(abspath, "utf8");
87
+ const contentStr = _fsextra.readFileSync(abspath, "utf8");
80
88
  const liquidParseError = (0, _liquid.validateLiquidSyntax)(contentStr);
81
89
  if (liquidParseError) {
82
90
  const error = new _error.JsonDataError(`points to a file that contains invalid liquid syntax (${relpath})\n\n` + (0, _error.formatErrors)([
@@ -91,7 +99,7 @@ const readExtractedFileSync = (relpath, dirCtx, objPathToFieldStr = "")=>{
91
99
  }
92
100
  // If the file is expected to contain decodable json, then parse the contentStr
93
101
  // as such.
94
- const fileName = _nodePath.basename(abspath.toLowerCase());
102
+ const fileName = _nodepath.basename(abspath.toLowerCase());
95
103
  const decodable = DECODABLE_JSON_FILES.has(fileName);
96
104
  const [content, jsonParseErrors] = decodable ? (0, _json.parseJson)(contentStr) : [
97
105
  contentStr,
@@ -124,8 +132,8 @@ const validateExtractedFilePath = (val, sourceFileAbspath, uniqueFilePaths, objP
124
132
  };
125
133
  const checkIfValidExtractedFilePathFormat = (relpath, sourceFileAbspath)=>{
126
134
  if (typeof relpath !== "string") return false;
127
- if (_nodePath.isAbsolute(relpath)) return false;
128
- const extractedFileAbspath = _nodePath.resolve(sourceFileAbspath, relpath);
129
- const pathDiff = _nodePath.relative(sourceFileAbspath, extractedFileAbspath);
135
+ if (_nodepath.isAbsolute(relpath)) return false;
136
+ const extractedFileAbspath = _nodepath.resolve(sourceFileAbspath, relpath);
137
+ const pathDiff = _nodepath.relative(sourceFileAbspath, extractedFileAbspath);
130
138
  return !pathDiff.startsWith("..");
131
139
  };
@@ -9,22 +9,41 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- translationRefDescription: ()=>translationRefDescription,
13
- formatLanguage: ()=>formatLanguage,
14
- isValidLocale: ()=>isValidLocale,
15
- isTranslationDir: ()=>isTranslationDir,
16
- buildTranslationFileCtx: ()=>buildTranslationFileCtx,
17
- parseTranslationRef: ()=>parseTranslationRef,
18
- ensureValidCommandTarget: ()=>ensureValidCommandTarget,
19
- lsTranslationDir: ()=>lsTranslationDir
12
+ SYSTEM_NAMESPACE: function() {
13
+ return SYSTEM_NAMESPACE;
14
+ },
15
+ buildTranslationFileCtx: function() {
16
+ return buildTranslationFileCtx;
17
+ },
18
+ ensureValidCommandTarget: function() {
19
+ return ensureValidCommandTarget;
20
+ },
21
+ formatLanguage: function() {
22
+ return formatLanguage;
23
+ },
24
+ isTranslationDir: function() {
25
+ return isTranslationDir;
26
+ },
27
+ isValidLocale: function() {
28
+ return isValidLocale;
29
+ },
30
+ lsTranslationDir: function() {
31
+ return lsTranslationDir;
32
+ },
33
+ parseTranslationRef: function() {
34
+ return parseTranslationRef;
35
+ },
36
+ translationRefDescription: function() {
37
+ return translationRefDescription;
38
+ }
20
39
  });
21
- const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
40
+ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
22
41
  const _core = require("@oclif/core");
23
- const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
24
- const _localeCodes = /*#__PURE__*/ _interopRequireDefault(require("locale-codes"));
42
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
43
+ const _localecodes = /*#__PURE__*/ _interop_require_default(require("locale-codes"));
25
44
  const _fs = require("../../helpers/fs");
26
- const _processorIsomorphic = require("./processor.isomorphic");
27
- function _interopRequireDefault(obj) {
45
+ const _processorisomorphic = require("./processor.isomorphic");
46
+ function _interop_require_default(obj) {
28
47
  return obj && obj.__esModule ? obj : {
29
48
  default: obj
30
49
  };
@@ -37,7 +56,7 @@ function _getRequireWildcardCache(nodeInterop) {
37
56
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
38
57
  })(nodeInterop);
39
58
  }
40
- function _interopRequireWildcard(obj, nodeInterop) {
59
+ function _interop_require_wildcard(obj, nodeInterop) {
41
60
  if (!nodeInterop && obj && obj.__esModule) {
42
61
  return obj;
43
62
  }
@@ -50,7 +69,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
50
69
  if (cache && cache.has(obj)) {
51
70
  return cache.get(obj);
52
71
  }
53
- var newObj = {};
72
+ var newObj = {
73
+ __proto__: null
74
+ };
54
75
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
76
  for(var key in obj){
56
77
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -73,20 +94,21 @@ Translation ref is a identifier string that refers to a unique translation.
73
94
  If a translation has no namespace, it is the same as the locale, e.g. \`en\`.
74
95
  If namespaced, it is formatted as namespace.locale, e.g. \`admin.en\`.
75
96
  `.trim();
97
+ const SYSTEM_NAMESPACE = "system";
76
98
  const formatLanguage = (translation)=>{
77
- const lang = _localeCodes.default.getByTag(translation.locale_code);
99
+ const lang = _localecodes.default.getByTag(translation.locale_code);
78
100
  return lang.location ? `${lang.name}, ${lang.location}` : lang.name;
79
101
  };
80
- const isValidLocale = (localeCode)=>Boolean(_localeCodes.default.getByTag(localeCode));
102
+ const isValidLocale = (localeCode)=>Boolean(_localecodes.default.getByTag(localeCode));
81
103
  const isTranslationDir = (dirPath)=>{
82
- const locale = _nodePath.basename(dirPath);
104
+ const locale = _nodepath.basename(dirPath);
83
105
  return isValidLocale(locale);
84
106
  };
85
107
  const buildTranslationFileCtx = async (dirPath, localeCode, namespace)=>{
86
- const ref = (0, _processorIsomorphic.formatRef)(localeCode, namespace);
87
- const filename = (0, _processorIsomorphic.formatFileName)(ref);
88
- const abspath = _nodePath.resolve(dirPath, filename);
89
- const exists = await _fsExtra.pathExists(abspath);
108
+ const ref = (0, _processorisomorphic.formatRef)(localeCode, namespace);
109
+ const filename = (0, _processorisomorphic.formatFileName)(ref);
110
+ const abspath = _nodepath.resolve(dirPath, filename);
111
+ const exists = await _fsextra.pathExists(abspath);
90
112
  return {
91
113
  ref,
92
114
  localeCode,
@@ -115,8 +137,8 @@ const parseTranslationRef = (reference)=>{
115
137
  return undefined;
116
138
  };
117
139
  const ensureValidCommandTarget = async (props, runContext)=>{
118
- const { flags , args } = props;
119
- const { commandId , resourceDir: resourceDirCtx , cwd: runCwd } = runContext;
140
+ const { flags, args } = props;
141
+ const { commandId, resourceDir: resourceDirCtx, cwd: runCwd } = runContext;
120
142
  // Error, trying to run the command not in a translation directory.
121
143
  if (resourceDirCtx && resourceDirCtx.type !== "translation") {
122
144
  return _core.ux.error(`Cannot run ${commandId} inside a ${resourceDirCtx.type} directory`);
@@ -151,12 +173,12 @@ const ensureValidCommandTarget = async (props, runContext)=>{
151
173
  if (!parsedRef) {
152
174
  return _core.ux.error(`Invalid translation ref \`${args.translationRef}\`, use valid <locale> or <namespace>.<locale> for namespaced translations`);
153
175
  }
154
- const { localeCode , namespace } = parsedRef;
176
+ const { localeCode, namespace } = parsedRef;
155
177
  // If we are in the translation dir, make sure the locale matches.
156
178
  if (resourceDirCtx && resourceDirCtx.key !== localeCode) {
157
179
  return _core.ux.error(`Cannot run ${commandId} with \`${args.translationRef}\` inside a ${resourceDirCtx.key} directory`);
158
180
  }
159
- const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : _nodePath.resolve(runCwd, localeCode);
181
+ const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : _nodepath.resolve(runCwd, localeCode);
160
182
  // Got translationRef arg but no --all flag, which means target only a single
161
183
  // translation file.
162
184
  if (!flags.all) {
@@ -183,17 +205,17 @@ const ensureValidCommandTarget = async (props, runContext)=>{
183
205
  };
184
206
  };
185
207
  const lsTranslationDir = async (pathToDir)=>{
186
- const localeCode = _nodePath.basename(pathToDir).toLowerCase();
187
- const dirents = await _fsExtra.readdir(pathToDir, {
208
+ const localeCode = _nodepath.basename(pathToDir).toLowerCase();
209
+ const dirents = await _fsextra.readdir(pathToDir, {
188
210
  withFileTypes: true
189
211
  });
190
212
  return dirents.filter((dirent)=>{
191
213
  if (dirent.isDirectory()) return false;
192
214
  const filename = dirent.name.toLowerCase();
193
215
  if (!filename.endsWith(`${localeCode}.json`)) return false;
194
- const { name: translationRef } = _nodePath.parse(filename);
216
+ const { name: translationRef } = _nodepath.parse(filename);
195
217
  const parsedRef = parseTranslationRef(translationRef);
196
218
  if (!parsedRef) return false;
197
219
  return true;
198
- }).map((dirent)=>_nodePath.resolve(pathToDir, dirent.name));
220
+ }).map((dirent)=>_nodepath.resolve(pathToDir, dirent.name));
199
221
  };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./helpers"), exports);
6
+ _export_star(require("./processor.isomorphic"), exports);
7
+ _export_star(require("./reader"), exports);
8
+ _export_star(require("./types"), exports);
9
+ _export_star(require("./writer"), exports);
10
+ function _export_star(from, to) {
11
+ Object.keys(from).forEach(function(k) {
12
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
13
+ Object.defineProperty(to, k, {
14
+ enumerable: true,
15
+ get: function() {
16
+ return from[k];
17
+ }
18
+ });
19
+ }
20
+ });
21
+ return from;
22
+ }
@@ -9,9 +9,15 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- formatRef: ()=>formatRef,
13
- formatFileName: ()=>formatFileName,
14
- buildTranslationDirBundle: ()=>buildTranslationDirBundle
12
+ buildTranslationDirBundle: function() {
13
+ return buildTranslationDirBundle;
14
+ },
15
+ formatFileName: function() {
16
+ return formatFileName;
17
+ },
18
+ formatRef: function() {
19
+ return formatRef;
20
+ }
15
21
  });
16
22
  const formatRef = (localeCode, namespace)=>namespace ? `${namespace}.${localeCode}` : localeCode;
17
23
  const formatFileName = (input)=>{