@zokugun/artifact 0.5.2 → 0.6.0

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 (216) hide show
  1. package/bin/artifact +1 -1
  2. package/lib/cli.d.ts +1 -0
  3. package/lib/cli.js +12 -4
  4. package/lib/commands/add.d.ts +6 -0
  5. package/lib/commands/add.js +47 -36
  6. package/lib/commands/index.d.ts +4 -0
  7. package/lib/commands/index.js +9 -7
  8. package/lib/commands/list.d.ts +1 -0
  9. package/lib/commands/list.js +13 -8
  10. package/lib/commands/remove.d.ts +6 -0
  11. package/lib/commands/remove.js +79 -0
  12. package/lib/commands/update.d.ts +5 -0
  13. package/lib/commands/update.js +43 -39
  14. package/lib/compositors/compose.d.ts +7 -0
  15. package/lib/compositors/compose.js +13 -13
  16. package/lib/compositors/fork.d.ts +3 -0
  17. package/lib/compositors/fork.js +4 -4
  18. package/lib/compositors/index.d.ts +6 -0
  19. package/lib/compositors/index.js +12 -12
  20. package/lib/compositors/json.d.ts +2 -0
  21. package/lib/compositors/json.js +14 -12
  22. package/lib/compositors/map-sort.d.ts +2 -0
  23. package/lib/compositors/map-sort.js +2 -2
  24. package/lib/compositors/rc.d.ts +2 -0
  25. package/lib/compositors/rc.js +13 -10
  26. package/lib/compositors/yaml.d.ts +2 -0
  27. package/lib/compositors/yaml.js +8 -11
  28. package/lib/configs/index.d.ts +3 -0
  29. package/lib/configs/index.js +3 -2
  30. package/lib/configs/install/index.d.ts +3 -0
  31. package/lib/configs/install/index.js +6 -6
  32. package/lib/configs/install/read-install-config.d.ts +6 -0
  33. package/lib/configs/install/read-install-config.js +123 -80
  34. package/lib/configs/install/update-install-config.d.ts +2 -0
  35. package/lib/configs/install/write-install-config.d.ts +5 -0
  36. package/lib/configs/install/write-install-config.js +17 -9
  37. package/lib/configs/package/index.d.ts +1 -0
  38. package/lib/configs/package/index.js +2 -2
  39. package/lib/configs/package/read-package-config.d.ts +3 -0
  40. package/lib/configs/package/read-package-config.js +159 -40
  41. package/lib/configs/uninstall/index.d.ts +1 -0
  42. package/lib/configs/uninstall/index.js +5 -0
  43. package/lib/configs/uninstall/update-uninstall-config.d.ts +2 -0
  44. package/lib/configs/uninstall/update-uninstall-config.js +6 -0
  45. package/lib/configs/utils/constants.d.ts +11 -0
  46. package/lib/configs/utils/constants.js +24 -0
  47. package/lib/configs/utils/is-transform.d.ts +2 -0
  48. package/lib/configs/utils/is-transform.js +16 -0
  49. package/lib/configs/utils/merge-upsert-property.d.ts +3 -0
  50. package/lib/configs/utils/merge-upsert-property.js +68 -0
  51. package/lib/configs/utils/normalize-file-always.d.ts +3 -0
  52. package/lib/configs/utils/normalize-file-always.js +28 -0
  53. package/lib/configs/utils/normalize-file-uninstall.d.ts +3 -0
  54. package/lib/configs/utils/normalize-file-uninstall.js +31 -0
  55. package/lib/configs/utils/normalize-file-upsert.d.ts +3 -0
  56. package/lib/configs/utils/normalize-file-upsert.js +54 -0
  57. package/lib/journeys/commitlint/index.d.ts +2 -0
  58. package/lib/journeys/commitlint/index.js +15 -15
  59. package/lib/journeys/config.ts/index.d.ts +2 -0
  60. package/lib/journeys/config.ts/index.js +5 -5
  61. package/lib/journeys/default/index.d.ts +2 -0
  62. package/lib/journeys/default/index.js +11 -14
  63. package/lib/journeys/fixpack/index.d.ts +2 -0
  64. package/lib/journeys/fixpack/index.js +13 -13
  65. package/lib/journeys/gitignore/index.d.ts +2 -0
  66. package/lib/journeys/gitignore/index.js +5 -5
  67. package/lib/journeys/ignore/index.d.ts +2 -0
  68. package/lib/journeys/ignore/index.js +5 -5
  69. package/lib/journeys/index.d.ts +2 -0
  70. package/lib/journeys/index.js +20 -20
  71. package/lib/journeys/npmignore/index.d.ts +2 -0
  72. package/lib/journeys/npmignore/index.js +5 -5
  73. package/lib/journeys/package/index.d.ts +2 -0
  74. package/lib/journeys/package/index.js +27 -30
  75. package/lib/journeys/rc/index.d.ts +2 -0
  76. package/lib/journeys/rc/index.js +12 -12
  77. package/lib/journeys/tsconfig/index.d.ts +2 -0
  78. package/lib/journeys/tsconfig/index.js +13 -16
  79. package/lib/parsers/json.d.ts +2 -0
  80. package/lib/parsers/jsonc/index.d.ts +2 -0
  81. package/lib/parsers/jsonc/index.js +4 -4
  82. package/lib/parsers/jsonc/parse.d.ts +5 -0
  83. package/lib/parsers/jsonc/parse.js +1 -13
  84. package/lib/parsers/jsonc/stringify.d.ts +2 -0
  85. package/lib/parsers/jsonc/stringify.js +2 -2
  86. package/lib/parsers/jsonc/transform.d.ts +10 -0
  87. package/lib/parsers/yaml.d.ts +2 -0
  88. package/lib/routes/command.d.ts +4 -0
  89. package/lib/routes/command.js +10 -10
  90. package/lib/routes/index.d.ts +8 -0
  91. package/lib/routes/index.js +17 -15
  92. package/lib/routes/lines-concat.d.ts +4 -0
  93. package/lib/routes/lines-concat.js +7 -7
  94. package/lib/routes/list-concat.d.ts +4 -0
  95. package/lib/routes/list-concat.js +3 -7
  96. package/lib/routes/list-sort-concat.d.ts +4 -0
  97. package/lib/routes/list-sort-concat.js +1 -1
  98. package/lib/routes/map-concat.d.ts +4 -0
  99. package/lib/routes/map-concat.js +1 -1
  100. package/lib/routes/map-delete.d.ts +4 -0
  101. package/lib/routes/map-delete.js +32 -0
  102. package/lib/routes/overwrite.d.ts +4 -0
  103. package/lib/routes/overwrite.js +2 -2
  104. package/lib/routes/primitive.d.ts +4 -0
  105. package/lib/routes/primitive.js +3 -3
  106. package/lib/steps/apply-formatting.d.ts +8 -0
  107. package/lib/steps/apply-formatting.js +19 -15
  108. package/lib/steps/configure-branches.d.ts +3 -0
  109. package/lib/steps/configure-branches.js +8 -5
  110. package/lib/steps/configure-install-file-actions.d.ts +3 -0
  111. package/lib/steps/configure-install-file-actions.js +41 -86
  112. package/lib/steps/configure-uninstall-file-actions.d.ts +3 -0
  113. package/lib/steps/configure-uninstall-file-actions.js +53 -0
  114. package/lib/steps/configure-update-file-actions.d.ts +3 -0
  115. package/lib/steps/configure-update-file-actions.js +64 -97
  116. package/lib/steps/copy-binary-files.d.ts +3 -0
  117. package/lib/steps/copy-binary-files.js +24 -11
  118. package/lib/steps/execute-first-block.d.ts +3 -0
  119. package/lib/steps/execute-first-block.js +35 -14
  120. package/lib/steps/execute-next-block.d.ts +3 -0
  121. package/lib/steps/execute-next-block.js +8 -3
  122. package/lib/steps/index.d.ts +54 -0
  123. package/lib/steps/index.js +76 -54
  124. package/lib/steps/insert-final-new-line.d.ts +6 -0
  125. package/lib/steps/insert-final-new-line.js +13 -1
  126. package/lib/steps/merge-text-files.d.ts +3 -0
  127. package/lib/steps/merge-text-files.js +41 -27
  128. package/lib/steps/read-editor-config.d.ts +3 -0
  129. package/lib/steps/read-editor-config.js +21 -26
  130. package/lib/steps/read-files.d.ts +3 -0
  131. package/lib/steps/read-files.js +19 -8
  132. package/lib/steps/read-incoming-config.d.ts +3 -0
  133. package/lib/steps/read-incoming-config.js +7 -5
  134. package/lib/steps/read-incoming-package.d.ts +3 -0
  135. package/lib/steps/read-incoming-package.js +12 -7
  136. package/lib/steps/remove-files.d.ts +3 -0
  137. package/lib/steps/remove-files.js +10 -4
  138. package/lib/steps/rename-files.d.ts +3 -0
  139. package/lib/steps/rename-files.js +25 -0
  140. package/lib/steps/replace-templates.d.ts +3 -0
  141. package/lib/steps/replace-templates.js +19 -5
  142. package/lib/steps/transform-untouched-files.d.ts +3 -0
  143. package/lib/steps/transform-untouched-files.js +73 -0
  144. package/lib/steps/unmerge-text-files.d.ts +3 -0
  145. package/lib/steps/unmerge-text-files.js +63 -0
  146. package/lib/steps/validate-newer-package.d.ts +3 -0
  147. package/lib/steps/validate-newer-package.js +4 -2
  148. package/lib/steps/validate-not-present-package.d.ts +3 -0
  149. package/lib/steps/validate-not-present-package.js +7 -4
  150. package/lib/steps/validate-present-package.d.ts +3 -0
  151. package/lib/steps/validate-present-package.js +24 -0
  152. package/lib/steps/write-text-files.d.ts +3 -0
  153. package/lib/steps/write-text-files.js +16 -7
  154. package/lib/types/binary-file.d.ts +4 -0
  155. package/lib/types/command.d.ts +5 -0
  156. package/lib/types/config.d.ts +58 -0
  157. package/lib/types/context.d.ts +56 -0
  158. package/lib/types/format.d.ts +10 -0
  159. package/lib/types/step.d.ts +3 -0
  160. package/lib/types/text-file.d.ts +7 -0
  161. package/lib/types/travel.d.ts +14 -0
  162. package/lib/utils/apply-transforms.d.ts +2 -0
  163. package/lib/utils/apply-transforms.js +48 -0
  164. package/lib/utils/build-journey-plan.d.ts +2 -0
  165. package/lib/utils/build-route.d.ts +3 -0
  166. package/lib/utils/build-route.js +92 -0
  167. package/lib/utils/build-travel-plan.d.ts +2 -0
  168. package/lib/utils/build-travel.d.ts +3 -0
  169. package/lib/utils/build-travel.js +32 -0
  170. package/lib/utils/command/dedupe-strings.d.ts +1 -0
  171. package/lib/utils/command/index.d.ts +8 -0
  172. package/lib/utils/command/index.js +14 -14
  173. package/lib/utils/command/join-command.d.ts +2 -0
  174. package/lib/utils/command/merge-and-chains.d.ts +1 -0
  175. package/lib/utils/command/merge-and-chains.js +21 -21
  176. package/lib/utils/command/merge-command-records.d.ts +2 -0
  177. package/lib/utils/command/merge-command-records.js +43 -22
  178. package/lib/utils/command/merge-flag-tokens.d.ts +1 -0
  179. package/lib/utils/command/merge-flag-tokens.js +1 -1
  180. package/lib/utils/command/merge-flags-as-string.d.ts +4 -0
  181. package/lib/utils/command/merge-flags-as-string.js +4 -4
  182. package/lib/utils/command/merge-or-segments.d.ts +1 -0
  183. package/lib/utils/command/merge-or-segments.js +28 -28
  184. package/lib/utils/command/merge-parts-by-prefix.d.ts +1 -0
  185. package/lib/utils/command/merge-parts-by-prefix.js +6 -6
  186. package/lib/utils/command/merge-semicolon-segments.d.ts +1 -0
  187. package/lib/utils/command/merge-semicolon-segments.js +35 -35
  188. package/lib/utils/command/merge-with-semicolon-mix.d.ts +1 -0
  189. package/lib/utils/command/merge-with-semicolon-mix.js +12 -12
  190. package/lib/utils/command/prefix-of-command.d.ts +1 -0
  191. package/lib/utils/command/prefix-of-command.js +2 -2
  192. package/lib/utils/command/split-chain.d.ts +1 -0
  193. package/lib/utils/command/split-command.d.ts +2 -0
  194. package/lib/utils/command/split-command.js +8 -8
  195. package/lib/utils/command/split-prefix-and-flags.d.ts +4 -0
  196. package/lib/utils/command/split-prefix-and-flags.js +5 -5
  197. package/lib/utils/command/split-segments.d.ts +1 -0
  198. package/lib/utils/detect-indent.d.ts +5 -0
  199. package/lib/utils/detect-indent.js +60 -0
  200. package/lib/utils/flow.d.ts +3 -0
  201. package/lib/utils/flow.js +12 -0
  202. package/lib/utils/get-format.d.ts +2 -0
  203. package/lib/utils/get-format.js +19 -0
  204. package/lib/utils/has-final-new-line.d.ts +1 -0
  205. package/lib/utils/has-final-new-line.js +7 -0
  206. package/lib/utils/read-buffer.d.ts +2 -0
  207. package/lib/utils/resolve-request.d.ts +3 -0
  208. package/lib/utils/resolve-request.js +4 -3
  209. package/lib/utils/template.d.ts +17 -0
  210. package/lib/utils/template.js +79 -57
  211. package/lib/utils/to-lines.d.ts +1 -0
  212. package/lib/utils/trim-final-newline.d.ts +1 -0
  213. package/lib/utils/try-json.d.ts +1 -0
  214. package/lib/utils/try-json.js +2 -2
  215. package/package.json +123 -101
  216. package/lib/utils/dev-null.js +0 -7
@@ -5,62 +5,181 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readPackageConfig = readPackageConfig;
7
7
  const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
9
+ const is_it_type_1 = require("@zokugun/is-it-type");
10
+ const xtry_1 = require("@zokugun/xtry");
9
11
  const yaml_1 = __importDefault(require("yaml"));
10
- const places = [
11
- {
12
- name: '.artifactrc.yml',
13
- type: 'yaml',
14
- },
15
- {
16
- name: '.artifactrc.yaml',
17
- type: 'yaml',
18
- },
19
- {
20
- name: '.artifactrc.json',
21
- type: 'json',
22
- },
23
- {
24
- name: '.artifactrc',
25
- },
26
- ];
12
+ const constants_js_1 = require("../utils/constants.js");
13
+ const merge_upsert_property_js_1 = require("../utils/merge-upsert-property.js");
14
+ const normalize_file_always_js_1 = require("../utils/normalize-file-always.js");
15
+ const normalize_file_uninstall_js_1 = require("../utils/normalize-file-uninstall.js");
16
+ const normalize_file_upsert_js_1 = require("../utils/normalize-file-upsert.js");
27
17
  async function readPackageConfig(targetPath) {
28
18
  let content;
19
+ let name;
29
20
  let type;
30
- for (const place of places) {
31
- try {
32
- content = await fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
33
- type = place.type;
34
- break;
35
- }
36
- catch {
21
+ for (const place of constants_js_1.CONFIG_LOCATIONS) {
22
+ const result = await async_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf8');
23
+ if (!result.fails) {
24
+ content = result.value;
25
+ ({ name, type } = place);
37
26
  }
38
27
  }
39
28
  if (!content) {
40
- return {
41
- install: {},
42
- update: {},
43
- };
29
+ return normalizeConfig(content, name);
44
30
  }
45
- let config;
46
31
  if (type === 'json') {
47
- config = JSON.parse(content);
32
+ return normalizeConfig(JSON.parse(content), name);
48
33
  }
49
34
  else if (type === 'yaml') {
50
- config = yaml_1.default.parse(content);
35
+ return normalizeConfig(yaml_1.default.parse(content), name);
51
36
  }
52
37
  else {
53
38
  try {
54
- config = JSON.parse(content);
55
- type = 'json';
39
+ return normalizeConfig(JSON.parse(content), name);
56
40
  }
57
41
  catch {
58
- config = yaml_1.default.parse(content);
59
- type = 'yaml';
42
+ return normalizeConfig(yaml_1.default.parse(content), name);
60
43
  }
61
44
  }
62
- if (typeof config.update === 'undefined') {
63
- config.update = {};
64
- }
65
- return config;
66
45
  }
46
+ function normalizeConfig(data, source) {
47
+ let constants = {};
48
+ let xtends;
49
+ const install = {};
50
+ let orphan = false;
51
+ const uninstall = {};
52
+ let update = {};
53
+ let variables = {};
54
+ let variants = {};
55
+ if (!data) {
56
+ return (0, xtry_1.ok)({
57
+ constants,
58
+ extends: xtends,
59
+ install,
60
+ orphan,
61
+ uninstall,
62
+ update,
63
+ variables,
64
+ variants,
65
+ });
66
+ }
67
+ if (!(0, is_it_type_1.isRecord)(data)) {
68
+ return (0, xtry_1.err)(`Config file ${source} must export an object.`);
69
+ }
70
+ if ((0, is_it_type_1.isString)(data.$schema)) {
71
+ const match = constants_js_1.VERSION_PACKAGE_REGEX.exec(data.$schema);
72
+ if (!match) {
73
+ return (0, xtry_1.err)(`Cannot validate the "$schema" in the package's "${source}".`);
74
+ }
75
+ const version = Number.parseInt(match[2], 10);
76
+ if (version > constants_js_1.MAX_VERSION) {
77
+ return (0, xtry_1.err)(`Don't support newer version (v${version}) in the package's "${source}".`);
78
+ }
79
+ }
80
+ if ((0, is_it_type_1.isRecord)(data.constants, (_key, value) => (0, is_it_type_1.isString)(value))) {
81
+ constants = data.constants;
82
+ }
83
+ if ((0, is_it_type_1.isString)(data.extends)) {
84
+ xtends = data.extends;
85
+ }
86
+ else if ((0, is_it_type_1.isNumber)(data.extends)) {
87
+ xtends = String(data.extends);
88
+ }
89
+ if (data.orphan === true) {
90
+ orphan = true;
91
+ }
92
+ if ((0, is_it_type_1.isRecord)(data.variables, (_key, value) => (0, is_it_type_1.isString)(value))) {
93
+ variables = data.variables;
94
+ }
95
+ if ((0, is_it_type_1.isRecord)(data.variants, (_key, value) => (0, is_it_type_1.isString)(value) || (0, is_it_type_1.isNumber)(value))) {
96
+ variants = Object.fromEntries(Object.entries(data.variants).map(([key, value]) => [key, (0, is_it_type_1.isNumber)(value) ? String(value) : value]));
97
+ }
98
+ if ((0, is_it_type_1.isRecord)(data.always)) {
99
+ for (const [key, value] of Object.entries(data.always)) {
100
+ const normalized = (0, normalize_file_always_js_1.normalizeFileAlways)(value);
101
+ if (normalized.fails) {
102
+ return normalized;
103
+ }
104
+ const { ifExists, transforms } = normalized.value;
105
+ install[key] = {
106
+ ...normalized.value,
107
+ ifMissing: 'merge',
108
+ };
109
+ uninstall[key] = {
110
+ ifExists: ifExists === 'force-merge' || ifExists === 'merge' || ifExists === 'overwrite' ? 'skip' : ifExists,
111
+ transforms,
112
+ };
113
+ update[key] = {
114
+ ...normalized.value,
115
+ ifMissing: 'merge',
116
+ };
117
+ }
118
+ }
119
+ if ((0, is_it_type_1.isRecord)(data.upsert)) {
120
+ for (const [key, value] of Object.entries(data.upsert)) {
121
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'upsert');
122
+ if (normalized.fails) {
123
+ return normalized;
124
+ }
125
+ install[key] = normalized.value;
126
+ update[key] = {
127
+ ...normalized.value,
128
+ };
129
+ }
130
+ }
131
+ if ((0, is_it_type_1.isRecord)(data.install)) {
132
+ for (const [key, value] of Object.entries(data.install)) {
133
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'install');
134
+ if (normalized.fails) {
135
+ return normalized;
136
+ }
137
+ if (install[key]) {
138
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(key, update[key], normalized.value);
139
+ if (result.fails) {
140
+ return result;
141
+ }
142
+ }
143
+ install[key] = normalized.value;
144
+ }
145
+ }
146
+ if ((0, is_it_type_1.isRecord)(data.uninstall)) {
147
+ for (const [key, value] of Object.entries(data.uninstall)) {
148
+ const normalized = (0, normalize_file_uninstall_js_1.normalizeFileUninstall)(value);
149
+ if (normalized.fails) {
150
+ return normalized;
151
+ }
152
+ uninstall[key] = normalized.value;
153
+ }
154
+ }
155
+ if (data.update === false) {
156
+ update = false;
157
+ }
158
+ else if ((0, is_it_type_1.isRecord)(data.update)) {
159
+ for (const [key, value] of Object.entries(data.update)) {
160
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'update');
161
+ if (normalized.fails) {
162
+ return normalized;
163
+ }
164
+ if (update[key]) {
165
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(key, update[key], normalized.value);
166
+ if (result.fails) {
167
+ return result;
168
+ }
169
+ }
170
+ else {
171
+ update[key] = normalized.value;
172
+ }
173
+ }
174
+ }
175
+ return (0, xtry_1.ok)({
176
+ constants,
177
+ extends: xtends,
178
+ install,
179
+ orphan,
180
+ uninstall,
181
+ update,
182
+ variables,
183
+ variants,
184
+ });
185
+ } // }}}
@@ -0,0 +1 @@
1
+ export { updateUninstallConfig } from './update-uninstall-config.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateUninstallConfig = void 0;
4
+ var update_uninstall_config_js_1 = require("./update-uninstall-config.js");
5
+ Object.defineProperty(exports, "updateUninstallConfig", { enumerable: true, get: function () { return update_uninstall_config_js_1.updateUninstallConfig; } });
@@ -0,0 +1,2 @@
1
+ import { type ArtifactResult, type InstallConfig } from '../../types/config.js';
2
+ export declare function updateUninstallConfig(config: InstallConfig, { name }: ArtifactResult): void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateUninstallConfig = updateUninstallConfig;
4
+ function updateUninstallConfig(config, { name }) {
5
+ delete config.artifacts[name];
6
+ }
@@ -0,0 +1,11 @@
1
+ export declare const CONFIG_LOCATIONS: ({
2
+ name: string;
3
+ type: string;
4
+ } | {
5
+ name: string;
6
+ type?: undefined;
7
+ })[];
8
+ export declare const MAX_VERSION = 1;
9
+ export declare const VERSION_INSTALL_REGEX: RegExp;
10
+ export declare const VERSION_PACKAGE_REGEX: RegExp;
11
+ export declare const VERSION_RELEASE = "0.6.0";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION_RELEASE = exports.VERSION_PACKAGE_REGEX = exports.VERSION_INSTALL_REGEX = exports.MAX_VERSION = exports.CONFIG_LOCATIONS = void 0;
4
+ exports.CONFIG_LOCATIONS = [
5
+ {
6
+ name: '.artifactrc.yml',
7
+ type: 'yaml',
8
+ },
9
+ {
10
+ name: '.artifactrc.yaml',
11
+ type: 'yaml',
12
+ },
13
+ {
14
+ name: '.artifactrc.json',
15
+ type: 'json',
16
+ },
17
+ {
18
+ name: '.artifactrc',
19
+ },
20
+ ];
21
+ exports.MAX_VERSION = 1;
22
+ exports.VERSION_INSTALL_REGEX = /https:\/\/raw.githubusercontent.com\/zokugun\/artifact\/v([\d.]+)\/schemas\/v(\d+)\/install.json/;
23
+ exports.VERSION_PACKAGE_REGEX = /https:\/\/raw.githubusercontent.com\/zokugun\/artifact\/v([\d.]+)\/schemas\/v(\d+)\/package.json/;
24
+ exports.VERSION_RELEASE = '0.6.0';
@@ -0,0 +1,2 @@
1
+ import { type FileTransform } from '../../types/config.js';
2
+ export declare function isTransform(value: unknown): value is FileTransform;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTransform = isTransform;
4
+ const is_it_type_1 = require("@zokugun/is-it-type");
5
+ function isTransform(value) {
6
+ if (!(0, is_it_type_1.isRecord)(value)) {
7
+ return false;
8
+ }
9
+ if ((0, is_it_type_1.isNonNullable)(value.description) && !(0, is_it_type_1.isString)(value.description)) {
10
+ return false;
11
+ }
12
+ if ((0, is_it_type_1.isNullable)(value.jq) || !(0, is_it_type_1.isNonEmptyString)(value.jq)) {
13
+ return false;
14
+ }
15
+ return true;
16
+ }
@@ -0,0 +1,3 @@
1
+ import { type DResult } from '@zokugun/xtry';
2
+ import { type FileUpsert } from '../../types/config.js';
3
+ export declare function mergeUpsertProperty(key: string, oldValue: FileUpsert, newValue: FileUpsert): DResult;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeUpsertProperty = mergeUpsertProperty;
4
+ const xtry_1 = require("@zokugun/xtry");
5
+ const lodash_es_1 = require("lodash-es");
6
+ function mergeUpsertProperty(key, oldValue, newValue) {
7
+ if (newValue.filter) {
8
+ if (oldValue.filter) {
9
+ return (0, xtry_1.err)('Not Implemented: filter');
10
+ }
11
+ else {
12
+ oldValue.filter = newValue.filter;
13
+ }
14
+ }
15
+ if (newValue.ifExists && newValue.ifExists !== 'merge') {
16
+ if (oldValue.ifExists) {
17
+ if (oldValue.ifExists === 'merge' || oldValue.ifExists === newValue.ifExists) {
18
+ // pass
19
+ }
20
+ else {
21
+ return (0, xtry_1.err)('Not Implemented: ifExists');
22
+ }
23
+ }
24
+ else {
25
+ oldValue.ifExists = newValue.ifExists;
26
+ }
27
+ }
28
+ if (newValue.ifMissing && newValue.ifMissing !== 'merge') {
29
+ if (oldValue.ifMissing) {
30
+ if (oldValue.ifMissing === 'merge' || oldValue.ifMissing === newValue.ifMissing) {
31
+ // pass
32
+ }
33
+ else {
34
+ return (0, xtry_1.err)('Not Implemented: ifMissing');
35
+ }
36
+ }
37
+ else {
38
+ oldValue.ifMissing = newValue.ifMissing;
39
+ }
40
+ }
41
+ if (newValue.rename) {
42
+ if (oldValue.rename) {
43
+ return (0, xtry_1.err)('Not Implemented: rename');
44
+ }
45
+ else {
46
+ oldValue.rename = newValue.rename;
47
+ }
48
+ }
49
+ if (newValue.route) {
50
+ if (oldValue.route) {
51
+ return (0, xtry_1.err)('Not Implemented: route');
52
+ }
53
+ else {
54
+ oldValue.route = newValue.route;
55
+ }
56
+ }
57
+ if (newValue.transforms && newValue.transforms.length > 0) {
58
+ if (oldValue.transforms) {
59
+ if (!(0, lodash_es_1.isEqual)(oldValue.transforms, newValue.transforms)) {
60
+ return (0, xtry_1.err)(`There is a conflict on the "transforms" property for the "${key}" file`);
61
+ }
62
+ }
63
+ else {
64
+ oldValue.transforms = newValue.transforms;
65
+ }
66
+ }
67
+ return xtry_1.OK;
68
+ }
@@ -0,0 +1,3 @@
1
+ import { type DResult } from '@zokugun/xtry';
2
+ import { type FileAlways } from '../../types/config.js';
3
+ export declare function normalizeFileAlways(data: unknown): DResult<FileAlways>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFileAlways = normalizeFileAlways;
4
+ const is_it_type_1 = require("@zokugun/is-it-type");
5
+ const xtry_1 = require("@zokugun/xtry");
6
+ const is_transform_js_1 = require("./is-transform.js");
7
+ function normalizeFileAlways(data) {
8
+ if (!(0, is_it_type_1.isRecord)(data)) {
9
+ return (0, xtry_1.err)('"always" must be an object.');
10
+ }
11
+ let ifExists = 'merge';
12
+ let transforms = [];
13
+ if ((0, is_it_type_1.isString)(data.if_exists)) {
14
+ if (data.if_exists === 'overwrite' || data.if_exists === 'remove' || data.if_exists === 'skip') {
15
+ ifExists = data.if_exists;
16
+ }
17
+ }
18
+ else if (data.remove === true) {
19
+ ifExists = 'remove';
20
+ }
21
+ if ((0, is_it_type_1.isArray)(data.transforms, is_transform_js_1.isTransform)) {
22
+ transforms = data.transforms;
23
+ }
24
+ return (0, xtry_1.ok)({
25
+ ifExists,
26
+ transforms,
27
+ });
28
+ } // }}}
@@ -0,0 +1,3 @@
1
+ import { type DResult } from '@zokugun/xtry';
2
+ import { type FileUninstall } from '../../types/config.js';
3
+ export declare function normalizeFileUninstall(data: unknown): DResult<FileUninstall>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFileUninstall = normalizeFileUninstall;
4
+ const is_it_type_1 = require("@zokugun/is-it-type");
5
+ const xtry_1 = require("@zokugun/xtry");
6
+ const is_transform_js_1 = require("./is-transform.js");
7
+ function normalizeFileUninstall(data) {
8
+ if (!(0, is_it_type_1.isRecord)(data)) {
9
+ return (0, xtry_1.err)('"uninstall" must be an object.');
10
+ }
11
+ let ifExists = 'skip';
12
+ let transforms = [];
13
+ if ((0, is_it_type_1.isString)(data.if_exists)) {
14
+ if (data.if_exists === 'remove' || data.if_exists === 'unmerge') {
15
+ ifExists = data.if_exists;
16
+ }
17
+ }
18
+ else if (data.remove === true) {
19
+ ifExists = 'remove';
20
+ }
21
+ else if (data.unmerge === true) {
22
+ ifExists = 'unmerge';
23
+ }
24
+ if ((0, is_it_type_1.isArray)(data.transforms, is_transform_js_1.isTransform)) {
25
+ transforms = data.transforms;
26
+ }
27
+ return (0, xtry_1.ok)({
28
+ ifExists,
29
+ transforms,
30
+ });
31
+ } // }}}
@@ -0,0 +1,3 @@
1
+ import { type DResult } from '@zokugun/xtry';
2
+ import { type FileUpsert } from '../../types/config.js';
3
+ export declare function normalizeFileUpsert(data: unknown, name: 'install' | 'update' | 'upsert'): DResult<FileUpsert>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFileUpsert = normalizeFileUpsert;
4
+ const is_it_type_1 = require("@zokugun/is-it-type");
5
+ const xtry_1 = require("@zokugun/xtry");
6
+ const is_transform_js_1 = require("./is-transform.js");
7
+ function normalizeFileUpsert(data, name) {
8
+ if (!(0, is_it_type_1.isRecord)(data)) {
9
+ return (0, xtry_1.err)(`"${name}" must be an object.`);
10
+ }
11
+ let filter;
12
+ let ifExists = 'merge';
13
+ let ifMissing = 'merge';
14
+ let rename;
15
+ let route;
16
+ let transforms = [];
17
+ if ((0, is_it_type_1.isArray)(data.filter, is_it_type_1.isString)) {
18
+ filter = data.filter;
19
+ }
20
+ if ((0, is_it_type_1.isString)(data.if_exists)) {
21
+ if (data.if_exists === 'overwrite' || data.if_exists === 'remove' || data.if_exists === 'skip') {
22
+ ifExists = data.if_exists;
23
+ }
24
+ }
25
+ else if (data.overwrite === true) {
26
+ ifExists = 'overwrite';
27
+ }
28
+ else if (data.remove === true) {
29
+ ifExists = 'remove';
30
+ }
31
+ else if ((0, is_it_type_1.isBoolean)(data.update)) {
32
+ ifExists = data.update ? 'force-merge' : 'skip';
33
+ }
34
+ if (data.missing === false || data.if_missing === 'skip') {
35
+ ifMissing = 'skip';
36
+ }
37
+ if ((0, is_it_type_1.isString)(data.rename)) {
38
+ rename = data.rename;
39
+ }
40
+ if ((0, is_it_type_1.isRecord)(data.route)) {
41
+ route = data.route;
42
+ }
43
+ if ((0, is_it_type_1.isArray)(data.transforms, is_transform_js_1.isTransform)) {
44
+ transforms = data.transforms;
45
+ }
46
+ return (0, xtry_1.ok)({
47
+ filter,
48
+ ifExists,
49
+ ifMissing,
50
+ rename,
51
+ route,
52
+ transforms,
53
+ });
54
+ } // }}}
@@ -0,0 +1,2 @@
1
+ declare const _default: (basename: string) => import("../../types/travel.js").Journey | undefined;
2
+ export default _default;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const compositors_1 = require("../../compositors");
4
- const routes_1 = require("../../routes");
5
- const build_journey_plan_1 = require("../../utils/build-journey-plan");
6
- const build_travel_plan_1 = require("../../utils/build-travel-plan");
7
- const mainRoute = (0, compositors_1.compose)({
8
- extends: routes_1.listConcat,
9
- parserPreset: routes_1.primitive,
10
- rules: (0, compositors_1.compose)({
11
- $$default: routes_1.overwrite,
3
+ const index_js_1 = require("../../compositors/index.js");
4
+ const index_js_2 = require("../../routes/index.js");
5
+ const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
6
+ const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
7
+ const mainRoute = (0, index_js_1.compose)({
8
+ extends: index_js_2.listConcat,
9
+ parserPreset: index_js_2.primitive,
10
+ rules: (0, index_js_1.compose)({
11
+ $$default: index_js_2.overwrite,
12
12
  }),
13
- $$default: routes_1.primitive,
13
+ $$default: index_js_2.primitive,
14
14
  });
15
- const jsonRoute = (0, compositors_1.json)(mainRoute);
16
- const yamlRoute = (0, compositors_1.yaml)(mainRoute);
17
- const rcRoute = (0, compositors_1.rc)(mainRoute);
18
- const travelPlan = (0, build_travel_plan_1.buildTravelPlan)(['.commitlintrc.json', jsonRoute], ['.commitlintrc.yaml', yamlRoute], ['.commitlintrc.yml', yamlRoute], ['.commitlintrc', rcRoute]);
19
- exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
15
+ const jsonRoute = (0, index_js_1.json)(mainRoute);
16
+ const yamlRoute = (0, index_js_1.yaml)(mainRoute);
17
+ const rcRoute = (0, index_js_1.rc)(mainRoute);
18
+ const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)(['.commitlintrc.json', jsonRoute], ['.commitlintrc.yaml', yamlRoute], ['.commitlintrc.yml', yamlRoute], ['.commitlintrc', rcRoute]);
19
+ exports.default = (0, build_journey_plan_js_1.buildJourneyPlan)(travelPlan);
@@ -0,0 +1,2 @@
1
+ declare const _default: (basename: string) => import("../../types/travel.js").Journey | undefined;
2
+ export default _default;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const configdotts_merge_1 = require("@zokugun/configdotts-merge");
4
- const build_journey_plan_1 = require("../../utils/build-journey-plan");
5
- const build_travel_plan_1 = require("../../utils/build-travel-plan");
6
- function route({ current, incoming }) {
4
+ const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
5
+ const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
6
+ async function route({ current, incoming }) {
7
7
  const data = (0, configdotts_merge_1.merge)(current, incoming);
8
8
  return data;
9
9
  }
10
- const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/\.config\.ts/, route]);
11
- exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
10
+ const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)([/\.config\.ts/, route]);
11
+ exports.default = (0, build_journey_plan_js_1.buildJourneyPlan)(travelPlan);
@@ -0,0 +1,2 @@
1
+ declare const _default: (basename: string) => import("../../types/travel.js").Journey | undefined;
2
+ export default _default;
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
7
- const compositors_1 = require("../../compositors");
8
- const routes_1 = require("../../routes");
9
- const build_journey_plan_1 = require("../../utils/build-journey-plan");
10
- const build_travel_plan_1 = require("../../utils/build-travel-plan");
11
- const mainRoute = (0, compositors_1.compose)({
12
- $$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.mapConcat], routes_1.primitive),
3
+ const lodash_es_1 = require("lodash-es");
4
+ const index_js_1 = require("../../compositors/index.js");
5
+ const index_js_2 = require("../../routes/index.js");
6
+ const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
7
+ const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
8
+ const mainRoute = (0, index_js_1.compose)({
9
+ $$default: (0, index_js_1.fork)([Array.isArray, index_js_2.listConcat], [lodash_es_1.isPlainObject, index_js_2.mapConcat], index_js_2.primitive),
13
10
  });
14
- const jsonRoute = (0, compositors_1.json)(mainRoute);
15
- const yamlRoute = (0, compositors_1.yaml)(mainRoute);
16
- const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/\.json$/, jsonRoute], [/\.ya?ml$/, yamlRoute]);
17
- exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
11
+ const jsonRoute = (0, index_js_1.json)(mainRoute);
12
+ const yamlRoute = (0, index_js_1.yaml)(mainRoute);
13
+ const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)([/\.json$/, jsonRoute], [/\.ya?ml$/, yamlRoute]);
14
+ exports.default = (0, build_journey_plan_js_1.buildJourneyPlan)(travelPlan);
@@ -0,0 +1,2 @@
1
+ declare const _default: (basename: string) => import("../../types/travel.js").Journey | undefined;
2
+ export default _default;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const lodash_1 = require("lodash");
4
- const compositors_1 = require("../../compositors");
5
- const routes_1 = require("../../routes");
6
- const build_journey_plan_1 = require("../../utils/build-journey-plan");
7
- const build_travel_plan_1 = require("../../utils/build-travel-plan");
8
- const mainRoute = (0, compositors_1.compose)({
9
- sortToTop: routes_1.listSortConcat,
10
- $$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [lodash_1.isPlainObject, routes_1.mapConcat], routes_1.primitive),
3
+ const lodash_es_1 = require("lodash-es");
4
+ const index_js_1 = require("../../compositors/index.js");
5
+ const index_js_2 = require("../../routes/index.js");
6
+ const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
7
+ const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
8
+ const mainRoute = (0, index_js_1.compose)({
9
+ sortToTop: index_js_2.listSortConcat,
10
+ $$default: (0, index_js_1.fork)([Array.isArray, index_js_2.listConcat], [lodash_es_1.isPlainObject, index_js_2.mapConcat], index_js_2.primitive),
11
11
  });
12
- const jsonRoute = (0, compositors_1.json)(mainRoute);
13
- const yamlRoute = (0, compositors_1.yaml)(mainRoute);
14
- const rcRoute = (0, compositors_1.rc)(mainRoute);
15
- const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/^\.fixpackrc\.json$/, jsonRoute], [/^\.fixpackrc\.ya?ml$/, yamlRoute], [/^\.fixpackrc$/, rcRoute]);
16
- exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
12
+ const jsonRoute = (0, index_js_1.json)(mainRoute);
13
+ const yamlRoute = (0, index_js_1.yaml)(mainRoute);
14
+ const rcRoute = (0, index_js_1.rc)(mainRoute);
15
+ const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)([/^\.fixpackrc\.json$/, jsonRoute], [/^\.fixpackrc\.ya?ml$/, yamlRoute], [/^\.fixpackrc$/, rcRoute]);
16
+ exports.default = (0, build_journey_plan_js_1.buildJourneyPlan)(travelPlan);
@@ -0,0 +1,2 @@
1
+ declare const _default: (basename: string) => import("../../types/travel.js").Journey | undefined;
2
+ export default _default;