@zokugun/artifact 0.3.1 → 0.4.1

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 (66) hide show
  1. package/README.md +122 -37
  2. package/lib/cli.js +8 -2
  3. package/lib/commands/add.js +37 -44
  4. package/lib/commands/index.js +3 -1
  5. package/lib/commands/list.js +46 -0
  6. package/lib/commands/update.js +34 -20
  7. package/lib/compositors/compose.js +7 -12
  8. package/lib/compositors/fork.js +1 -2
  9. package/lib/compositors/json.js +18 -9
  10. package/lib/compositors/map-sort.js +1 -2
  11. package/lib/compositors/rc.js +18 -9
  12. package/lib/compositors/yaml.js +18 -9
  13. package/lib/configs/index.js +18 -0
  14. package/lib/configs/install/index.js +9 -0
  15. package/lib/configs/install/read-install-config.js +120 -0
  16. package/lib/configs/install/update-install-config.js +15 -0
  17. package/lib/{config/write-config.js → configs/install/write-install-config.js} +8 -9
  18. package/lib/configs/package/index.js +5 -0
  19. package/lib/{config/read-config.js → configs/package/read-package-config.js} +14 -32
  20. package/lib/journeys/config.ts/index.js +11 -0
  21. package/lib/journeys/index.js +3 -2
  22. package/lib/journeys/package/index.js +0 -1
  23. package/lib/parsers/json.js +2 -3
  24. package/lib/parsers/jsonc/parse.js +2 -3
  25. package/lib/parsers/jsonc/stringify.js +1 -2
  26. package/lib/parsers/yaml.js +2 -3
  27. package/lib/routes/command.js +1 -2
  28. package/lib/routes/lines-concat.js +1 -2
  29. package/lib/routes/list-concat.js +1 -2
  30. package/lib/routes/list-sort-concat.js +1 -2
  31. package/lib/routes/map-concat.js +1 -2
  32. package/lib/routes/overwrite.js +1 -2
  33. package/lib/routes/primitive.js +1 -2
  34. package/lib/steps/apply-formatting.js +5 -6
  35. package/lib/steps/configure-branches.js +69 -0
  36. package/lib/steps/configure-install-file-actions.js +151 -0
  37. package/lib/steps/{validate-updatability.js → configure-update-file-actions.js} +9 -10
  38. package/lib/steps/copy-binary-files.js +21 -13
  39. package/lib/steps/execute-first-block.js +112 -0
  40. package/lib/steps/execute-next-block.js +22 -0
  41. package/lib/steps/index.js +47 -9
  42. package/lib/steps/insert-final-new-line.js +3 -4
  43. package/lib/steps/merge-text-files.js +65 -36
  44. package/lib/steps/read-editor-config.js +22 -13
  45. package/lib/steps/read-files.js +3 -4
  46. package/lib/steps/read-incoming-config.js +9 -5
  47. package/lib/steps/read-incoming-package.js +12 -4
  48. package/lib/steps/remove-files.js +40 -0
  49. package/lib/steps/replace-templates.js +3 -4
  50. package/lib/steps/validate-newer-package.js +4 -5
  51. package/lib/steps/validate-not-present-package.js +4 -5
  52. package/lib/steps/write-text-files.js +3 -4
  53. package/lib/types/format.js +1 -1
  54. package/lib/utils/build-journey-plan.js +1 -2
  55. package/lib/utils/build-travel-plan.js +1 -2
  56. package/lib/utils/command/join-command.js +1 -2
  57. package/lib/utils/command/split-command.js +1 -2
  58. package/lib/utils/dev-null.js +1 -2
  59. package/lib/utils/read-buffer.js +5 -8
  60. package/lib/utils/resolve-request.js +42 -0
  61. package/lib/utils/template.js +21 -10
  62. package/lib/utils/to-lines.js +1 -2
  63. package/lib/utils/trim-final-newline.js +1 -2
  64. package/lib/utils/try-json.js +1 -2
  65. package/package.json +6 -4
  66. package/lib/config/index.js +0 -7
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.yaml = void 0;
36
+ exports.yaml = yaml;
27
37
  const lodash_1 = require("lodash");
28
38
  const YAML = __importStar(require("../parsers/yaml"));
29
39
  function fromYaml({ current, incoming, filters, ignores }) {
@@ -37,4 +47,3 @@ function fromYaml({ current, incoming, filters, ignores }) {
37
47
  function yaml(...routes) {
38
48
  return (0, lodash_1.flow)(fromYaml, ...routes, YAML.stringify);
39
49
  }
40
- exports.yaml = yaml;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./install"), exports);
18
+ __exportStar(require("./package"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateInstallConfig = exports.writeInstallConfig = exports.readInstallConfig = void 0;
4
+ var read_install_config_1 = require("./read-install-config");
5
+ Object.defineProperty(exports, "readInstallConfig", { enumerable: true, get: function () { return read_install_config_1.readInstallConfig; } });
6
+ var write_install_config_1 = require("./write-install-config");
7
+ Object.defineProperty(exports, "writeInstallConfig", { enumerable: true, get: function () { return write_install_config_1.writeInstallConfig; } });
8
+ var update_install_config_1 = require("./update-install-config");
9
+ Object.defineProperty(exports, "updateInstallConfig", { enumerable: true, get: function () { return update_install_config_1.updateInstallConfig; } });
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.readInstallConfig = readInstallConfig;
16
+ const path_1 = __importDefault(require("path"));
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const yaml_1 = __importDefault(require("yaml"));
19
+ const places = [
20
+ {
21
+ name: '.artifactrc.yml',
22
+ type: 'yaml',
23
+ },
24
+ {
25
+ name: '.artifactrc.yaml',
26
+ type: 'yaml',
27
+ },
28
+ {
29
+ name: '.artifactrc.json',
30
+ type: 'json',
31
+ },
32
+ {
33
+ name: '.artifactrc',
34
+ },
35
+ ];
36
+ function readInstallConfig(targetPath) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ let content;
39
+ let name;
40
+ let type;
41
+ for (const place of places) {
42
+ try {
43
+ content = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
44
+ name = place.name;
45
+ type = place.type;
46
+ break;
47
+ }
48
+ catch (_a) {
49
+ }
50
+ }
51
+ if (!content) {
52
+ return {
53
+ config: {
54
+ artifacts: {},
55
+ install: {},
56
+ update: {},
57
+ },
58
+ configStats: {
59
+ name: '.artifactrc.yml',
60
+ type: 'yaml',
61
+ finalNewLine: true,
62
+ },
63
+ };
64
+ }
65
+ const finalNewLine = content.endsWith('\n');
66
+ let data;
67
+ if (type === 'json') {
68
+ data = JSON.parse(content);
69
+ }
70
+ else if (type === 'yaml') {
71
+ data = yaml_1.default.parse(content);
72
+ }
73
+ else {
74
+ try {
75
+ data = JSON.parse(content);
76
+ type = 'json';
77
+ }
78
+ catch (_b) {
79
+ data = yaml_1.default.parse(content);
80
+ type = 'yaml';
81
+ }
82
+ }
83
+ if (typeof data.update === 'undefined') {
84
+ data.update = {};
85
+ }
86
+ if (isOldInstallConfig(data)) {
87
+ const config = {
88
+ artifacts: {},
89
+ install: data.install,
90
+ update: data.update,
91
+ };
92
+ for (const { name, version } of data.artifacts) {
93
+ config.artifacts[name] = {
94
+ version,
95
+ };
96
+ }
97
+ return {
98
+ config,
99
+ configStats: {
100
+ name: name,
101
+ type,
102
+ finalNewLine,
103
+ },
104
+ };
105
+ }
106
+ else {
107
+ return {
108
+ config: data,
109
+ configStats: {
110
+ name: name,
111
+ type,
112
+ finalNewLine,
113
+ },
114
+ };
115
+ }
116
+ });
117
+ }
118
+ function isOldInstallConfig(config) {
119
+ return Array.isArray(config.artifacts);
120
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateInstallConfig = updateInstallConfig;
4
+ function updateInstallConfig(config, { name, version, provides, requires }) {
5
+ const artifact = {
6
+ version,
7
+ };
8
+ if (requires) {
9
+ artifact.requires = requires;
10
+ }
11
+ if (provides) {
12
+ artifact.provides = provides;
13
+ }
14
+ config.artifacts[name] = artifact;
15
+ }
@@ -12,20 +12,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.writeConfig = void 0;
15
+ exports.writeInstallConfig = writeInstallConfig;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
18
  const lodash_1 = require("lodash");
19
19
  const yaml_1 = __importDefault(require("yaml"));
20
- const apply_formatting_1 = require("../steps/apply-formatting");
21
- const insert_final_new_line_1 = require("../steps/insert-final-new-line");
22
- function writeConfig({ artifacts, update }, { name, finalNewLine, type }, formats, targetPath, options) {
23
- return __awaiter(this, void 0, void 0, function* () {
20
+ const apply_formatting_1 = require("../../steps/apply-formatting");
21
+ const insert_final_new_line_1 = require("../../steps/insert-final-new-line");
22
+ function writeInstallConfig(config_1, _a, formats_1, targetPath_1, options_1) {
23
+ return __awaiter(this, arguments, void 0, function* (config, { name, finalNewLine, type }, formats, targetPath, options) {
24
24
  const exported = {
25
- artifacts: [...artifacts],
25
+ artifacts: config.artifacts,
26
26
  };
27
- if (!(0, lodash_1.isPlainObject)(update) || !(0, lodash_1.isEmpty)(update)) {
28
- exported.update = update;
27
+ if (!(0, lodash_1.isPlainObject)(config.update) || !(0, lodash_1.isEmpty)(config.update)) {
28
+ exported.update = config.update;
29
29
  }
30
30
  const file = {
31
31
  name,
@@ -41,4 +41,3 @@ function writeConfig({ artifacts, update }, { name, finalNewLine, type }, format
41
41
  }
42
42
  });
43
43
  }
44
- exports.writeConfig = writeConfig;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readPackageConfig = void 0;
4
+ var read_package_config_1 = require("./read-package-config");
5
+ Object.defineProperty(exports, "readPackageConfig", { enumerable: true, get: function () { return read_package_config_1.readPackageConfig; } });
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.readConfig = void 0;
15
+ exports.readPackageConfig = readPackageConfig;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
18
  const yaml_1 = __importDefault(require("yaml"));
@@ -33,63 +33,45 @@ const places = [
33
33
  name: '.artifactrc',
34
34
  },
35
35
  ];
36
- function readConfig(targetPath) {
36
+ function readPackageConfig(targetPath) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- let data;
39
- let name;
38
+ let content;
40
39
  let type;
41
40
  for (const place of places) {
42
41
  try {
43
- data = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
44
- name = place.name;
42
+ content = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
45
43
  type = place.type;
46
44
  break;
47
45
  }
48
46
  catch (_a) {
49
47
  }
50
48
  }
51
- if (!data) {
52
- return [
53
- {
54
- artifacts: [],
55
- update: {},
56
- },
57
- {
58
- name: '.artifactrc.yml',
59
- type: 'yaml',
60
- finalNewLine: true,
61
- },
62
- ];
49
+ if (!content) {
50
+ return {
51
+ install: {},
52
+ update: {},
53
+ };
63
54
  }
64
- const finalNewLine = data.endsWith('\n');
65
55
  let config;
66
56
  if (type === 'json') {
67
- config = JSON.parse(data);
57
+ config = JSON.parse(content);
68
58
  }
69
59
  else if (type === 'yaml') {
70
- config = yaml_1.default.parse(data);
60
+ config = yaml_1.default.parse(content);
71
61
  }
72
62
  else {
73
63
  try {
74
- config = JSON.parse(data);
64
+ config = JSON.parse(content);
75
65
  type = 'json';
76
66
  }
77
67
  catch (_b) {
78
- config = yaml_1.default.parse(data);
68
+ config = yaml_1.default.parse(content);
79
69
  type = 'yaml';
80
70
  }
81
71
  }
82
72
  if (typeof config.update === 'undefined') {
83
73
  config.update = {};
84
74
  }
85
- return [
86
- config,
87
- {
88
- name: name,
89
- type,
90
- finalNewLine,
91
- },
92
- ];
75
+ return config;
93
76
  });
94
77
  }
95
- exports.readConfig = readConfig;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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 }) {
7
+ const data = (0, configdotts_merge_1.merge)(current, incoming);
8
+ return data;
9
+ }
10
+ const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/\.config\.ts/, route]);
11
+ exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getJourney = void 0;
6
+ exports.getJourney = getJourney;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const commitlint_1 = __importDefault(require("./commitlint"));
9
+ const config_ts_1 = __importDefault(require("./config.ts"));
9
10
  const default_1 = __importDefault(require("./default"));
10
11
  const fixpack_1 = __importDefault(require("./fixpack"));
11
12
  const gitignore_1 = __importDefault(require("./gitignore"));
@@ -23,6 +24,7 @@ const plans = [
23
24
  package_1.default,
24
25
  tsconfig_1.default,
25
26
  rc_1.default,
27
+ config_ts_1.default,
26
28
  default_1.default,
27
29
  ];
28
30
  function getJourney(filename) {
@@ -35,4 +37,3 @@ function getJourney(filename) {
35
37
  }
36
38
  return undefined;
37
39
  }
38
- exports.getJourney = getJourney;
@@ -39,7 +39,6 @@ const mainRoute = (0, compositors_1.compose)({
39
39
  'os',
40
40
  'cpu',
41
41
  'preferGlobal',
42
- 'private',
43
42
  ],
44
43
  $$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.mapConcat], routes_1.primitive),
45
44
  });
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringify = exports.parse = void 0;
3
+ exports.parse = parse;
4
+ exports.stringify = stringify;
4
5
  function parse(data) {
5
6
  return JSON.parse(data);
6
7
  }
7
- exports.parse = parse;
8
8
  function stringify(data) {
9
9
  return JSON.stringify(data, null, '\t');
10
10
  }
11
- exports.stringify = stringify;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parse = void 0;
3
+ exports.parse = parse;
4
4
  const jsonc_parser_1 = require("jsonc-parser");
5
5
  function parse(text) {
6
6
  if (!text) {
@@ -180,7 +180,7 @@ function parse(text) {
180
180
  },
181
181
  onError(error, _offset, _length, _startLine, _startCharacter) {
182
182
  // console.log('onError', error, _startLine, _startCharacter)
183
- if ((error === 3 /* PropertyNameExpected */ || error === 4 /* ValueExpected */) && lastKid) {
183
+ if ((error === 3 /* ParseErrorCode.PropertyNameExpected */ || error === 4 /* ParseErrorCode.ValueExpected */) && lastKid) {
184
184
  lastKid.separator = true;
185
185
  }
186
186
  },
@@ -191,4 +191,3 @@ function parse(text) {
191
191
  transform,
192
192
  };
193
193
  }
194
- exports.parse = parse;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringify = void 0;
3
+ exports.stringify = stringify;
4
4
  const lodash_1 = require("lodash");
5
5
  function stringify(data, transform = {}) {
6
6
  const result = format(data, '', transform);
7
7
  return result;
8
8
  }
9
- exports.stringify = stringify;
10
9
  function format(data, indentValue, transform, separator = false) {
11
10
  var _a;
12
11
  let result;
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.stringify = exports.parse = void 0;
6
+ exports.parse = parse;
7
+ exports.stringify = stringify;
7
8
  const yaml_1 = __importDefault(require("yaml"));
8
9
  function parse(data) {
9
10
  return yaml_1.default.parse(data);
10
11
  }
11
- exports.parse = parse;
12
12
  function stringify(data) {
13
13
  return yaml_1.default.stringify(data);
14
14
  }
15
- exports.stringify = stringify;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = void 0;
3
+ exports.command = command;
4
4
  const command_1 = require("../utils/command");
5
5
  const list_concat_1 = require("./list-concat");
6
6
  function command({ current, incoming }) {
@@ -43,4 +43,3 @@ function command({ current, incoming }) {
43
43
  }
44
44
  return (0, command_1.joinCommand)(result);
45
45
  }
46
- exports.command = command;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.linesConcat = void 0;
3
+ exports.linesConcat = linesConcat;
4
4
  const to_lines_1 = require("../utils/to-lines");
5
5
  const trim_final_newline_1 = require("../utils/trim-final-newline");
6
6
  const list_concat_1 = require("./list-concat");
@@ -19,4 +19,3 @@ function linesConcat({ current, incoming }) {
19
19
  });
20
20
  return result.join('\n');
21
21
  }
22
- exports.linesConcat = linesConcat;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.listConcat = void 0;
6
+ exports.listConcat = listConcat;
7
7
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
8
8
  const uniqWith_1 = __importDefault(require("lodash/uniqWith"));
9
9
  function listConcat({ current, incoming }) {
@@ -15,4 +15,3 @@ function listConcat({ current, incoming }) {
15
15
  }
16
16
  return (0, uniqWith_1.default)([...current, ...incoming], isEqual_1.default);
17
17
  }
18
- exports.listConcat = listConcat;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listSortConcat = void 0;
3
+ exports.listSortConcat = listSortConcat;
4
4
  function listSortConcat({ current, incoming }) {
5
5
  if (!incoming) {
6
6
  return current !== null && current !== void 0 ? current : [];
@@ -39,4 +39,3 @@ function listSortConcat({ current, incoming }) {
39
39
  const result = sorting.map((weight) => weight2values[weight]);
40
40
  return result;
41
41
  }
42
- exports.listSortConcat = listSortConcat;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapConcat = void 0;
3
+ exports.mapConcat = mapConcat;
4
4
  function mapConcat({ current, incoming }) {
5
5
  if (!incoming) {
6
6
  return current !== null && current !== void 0 ? current : {};
@@ -10,4 +10,3 @@ function mapConcat({ current, incoming }) {
10
10
  }
11
11
  return Object.assign(Object.assign({}, current), incoming);
12
12
  }
13
- exports.mapConcat = mapConcat;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.overwrite = void 0;
3
+ exports.overwrite = overwrite;
4
4
  function overwrite({ current, incoming }) {
5
5
  if (typeof incoming === 'undefined') {
6
6
  return current !== null && current !== void 0 ? current : [];
@@ -9,4 +9,3 @@ function overwrite({ current, incoming }) {
9
9
  return incoming;
10
10
  }
11
11
  }
12
- exports.overwrite = overwrite;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.primitive = void 0;
3
+ exports.primitive = primitive;
4
4
  function primitive({ current, incoming }) {
5
5
  if (typeof incoming === 'undefined') {
6
6
  return current !== null && current !== void 0 ? current : [];
@@ -15,4 +15,3 @@ function primitive({ current, incoming }) {
15
15
  return incoming;
16
16
  }
17
17
  }
18
- exports.primitive = primitive;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.applyFormatting = void 0;
15
+ exports.applyFormatting = applyFormatting;
16
16
  const detect_indent_1 = __importDefault(require("detect-indent"));
17
17
  const fnmatch_1 = __importDefault(require("editorconfig/src/lib/fnmatch"));
18
18
  const format_1 = require("../types/format");
@@ -55,16 +55,16 @@ function indentWithSpace(data, size) {
55
55
  }
56
56
  } // }}}
57
57
  function indentWithTab(data) {
58
- const { type, indent } = (0, detect_indent_1.default)(data);
59
- if (type === 'space') {
58
+ const { type, indent, amount } = (0, detect_indent_1.default)(data);
59
+ if (type === 'space' && amount > 1) {
60
60
  return data.replace(new RegExp(indent, 'gm'), '\t');
61
61
  }
62
62
  else {
63
63
  return data;
64
64
  }
65
65
  } // }}}
66
- function applyFormatting({ mergedTextFiles, formats }) {
67
- return __awaiter(this, void 0, void 0, function* () {
66
+ function applyFormatting(_a) {
67
+ return __awaiter(this, arguments, void 0, function* ({ mergedTextFiles, formats }) {
68
68
  for (const file of mergedTextFiles) {
69
69
  for (const format of formats) {
70
70
  if (fnmatch(file.name, format.glob)) {
@@ -75,4 +75,3 @@ function applyFormatting({ mergedTextFiles, formats }) {
75
75
  }
76
76
  });
77
77
  }
78
- exports.applyFormatting = applyFormatting;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.configureBranches = configureBranches;
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const globby_1 = __importDefault(require("globby"));
19
+ function configureBranches(context) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const cwd = node_path_1.default.join(context.incomingPath, 'branches');
22
+ if (yield fs_extra_1.default.pathExists(cwd)) {
23
+ const directories = yield (0, globby_1.default)('*', {
24
+ cwd,
25
+ onlyDirectories: true,
26
+ });
27
+ const bucket = [];
28
+ for (const directory of directories) {
29
+ const match = /^\[(@[\w-]+:[\w-]+|[\w-]+)(?::([\w-]+))?]$/.exec(directory);
30
+ if (match) {
31
+ const [branch, name, variant] = match;
32
+ const packageName = name.replace(/:/g, '/');
33
+ const artifact = context.config.artifacts[packageName];
34
+ let found = false;
35
+ if (artifact) {
36
+ if (variant) {
37
+ if (Array.isArray(artifact.requires)) {
38
+ if (artifact.requires.includes(variant)) {
39
+ found = true;
40
+ }
41
+ }
42
+ else if (Array.isArray(artifact.provides)) {
43
+ if (artifact.provides.includes(variant)) {
44
+ found = true;
45
+ }
46
+ }
47
+ else {
48
+ found = true;
49
+ }
50
+ }
51
+ else {
52
+ found = true;
53
+ }
54
+ }
55
+ if (found) {
56
+ bucket.push({
57
+ name: context.incomingName,
58
+ version: context.incomingVersion,
59
+ variant: context.incomingVariant,
60
+ branch,
61
+ incomingPath: node_path_1.default.join(cwd, directory),
62
+ });
63
+ }
64
+ }
65
+ }
66
+ context.blocks.unshift(...bucket);
67
+ }
68
+ });
69
+ }