@anolilab/multi-semantic-release 2.0.6 → 3.0.0-alpha.2

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.
@@ -1,23 +0,0 @@
1
- import { existsSync, lstatSync } from "node:fs";
2
- import { Writable } from "node:stream";
3
-
4
- import { add, checker } from "blork";
5
- import { WritableStreamBuffer } from "stream-buffers";
6
-
7
- // Get some checkers.
8
- const isAbsolute = checker("absolute");
9
-
10
- // Add a directory checker.
11
- // eslint-disable-next-line security/detect-non-literal-fs-filename
12
- add("directory", (v) => isAbsolute(v) && existsSync(v) && lstatSync(v).isDirectory(), "directory that exists in the filesystem");
13
-
14
- // Add a writable stream checker.
15
- add(
16
- "stream",
17
- // istanbul ignore next (not important)
18
- (v) => v instanceof Writable || v instanceof WritableStreamBuffer,
19
- "instance of stream.Writable or WritableStreamBuffer",
20
- );
21
-
22
- // eslint-disable-next-line simple-import-sort/exports
23
- export { ValueError, check } from "blork";
@@ -1,23 +0,0 @@
1
- import { isAbsolute, join, normalize } from "node:path";
2
-
3
- import { check } from "./blork.js";
4
-
5
- /**
6
- * Normalize and make a path absolute, optionally using a custom CWD.
7
- * Trims any trailing slashes from the path.
8
- * @param {string} path The path to normalize and make absolute.
9
- * @param {string} cwd=process.cwd() The CWD to prepend to the path to make it absolute.
10
- * @param cwd
11
- * @returns {string} The absolute and normalized path.
12
- * @internal
13
- */
14
- function cleanPath(path, cwd = process.cwd()) {
15
- check(path, "path: path");
16
- check(cwd, "cwd: absolute");
17
-
18
- // Normalize, absolutify, and trim trailing slashes from the path.
19
- return normalize(isAbsolute(path) ? path : join(cwd, path)).replace(/[/\\]+$/u, "");
20
- }
21
-
22
- // Exports.
23
- export default cleanPath;
@@ -1,38 +0,0 @@
1
- /**
2
- * Lifted and tweaked from semantic-release because we follow how they bump their packages/dependencies.
3
- * https://github.com/semantic-release/semantic-release/blob/master/lib/utils.js
4
- */
5
-
6
- import { gt, prerelease, rcompare } from "semver";
7
-
8
- /**
9
- * HOC that applies highest/lowest semver function.
10
- * @param {Function} predicate High order function to be called.
11
- * @param {string|undefined} version1 Version 1 to be compared with.
12
- * @param {string|undefined} version2 Version 2 to be compared with.
13
- * @returns {string|undefined} Highest or lowest version.
14
- * @internal
15
- */
16
- const _selectVersionBy = (predicate, version1, version2) => {
17
- if (predicate && version1 && version2) {
18
- return predicate(version1, version2) ? version1 : version2;
19
- }
20
-
21
- return version1 || version2;
22
- };
23
-
24
- /**
25
- * Gets highest semver function binding gt to the HOC selectVersionBy.
26
- */
27
- export const getHighestVersion = _selectVersionBy.bind(null, gt);
28
-
29
- /**
30
- * Retrieve the latest version from a list of versions.
31
- * @param {Array} versions Versions as string list.
32
- * @param {boolean|undefined} withPrerelease Prerelease flag.
33
- * @returns {string|undefined} Latest version.
34
- * @internal
35
- */
36
- export function getLatestVersion(versions, withPrerelease) {
37
- return versions.filter((version) => withPrerelease || !prerelease(version)).sort(rcompare)[0];
38
- }
@@ -1,21 +0,0 @@
1
- // eslint-disable-next-line you-dont-need-lodash-underscore/cast-array
2
- import { castArray, pickBy } from "lodash-es";
3
-
4
- const isNil = (value) => value == undefined;
5
-
6
- const mergeConfig = (a = {}, b = {}) => {
7
- return {
8
- ...a,
9
- // Remove `null` and `undefined` options so they can be replaced with default ones
10
- ...pickBy(b, (option) => !isNil(option)),
11
- // Treat nested objects differently as otherwise we'll loose undefined keys
12
- deps: {
13
- ...a.deps,
14
- ...pickBy(b.deps, (option) => !isNil(option)),
15
- },
16
- // Treat arrays differently by merging them
17
- ignorePackages: [...new Set([...castArray(a.ignorePackages || []), ...castArray(b.ignorePackages || [])])],
18
- };
19
- };
20
-
21
- export default mergeConfig;
@@ -1,24 +0,0 @@
1
- import detectIndent from "detect-indent";
2
- import { detectNewline } from "detect-newline";
3
-
4
- /**
5
- * Information about the format of a file.
6
- * @typedef FileFormat
7
- * @property {string|number} indent Indentation characters
8
- * @property {string} trailingWhitespace Trailing whitespace at the end of the file
9
- */
10
-
11
- /**
12
- * Detects the indentation and trailing whitespace of a file.
13
- * @param {string} contents contents of the file
14
- * @returns {FileFormat} Formatting of the file
15
- */
16
- function recognizeFormat(contents) {
17
- return {
18
- indent: detectIndent(contents).indent,
19
- trailingWhitespace: detectNewline(contents) || "",
20
- };
21
- }
22
-
23
- // Exports.
24
- export default recognizeFormat;
@@ -1,76 +0,0 @@
1
- /**
2
- * Converts a stream to an array
3
- * @param {ReadStream} stream
4
- * @returns {Promise<Array>}
5
- */
6
- export default function streamToArray(stream) {
7
- if (!stream.readable) {
8
- return Promise.resolve([]);
9
- }
10
-
11
- // eslint-disable-next-line compat/compat
12
- return new Promise((resolve, reject) => {
13
- // stream is already ended
14
- if (!stream.readable) {
15
- resolve([]);
16
-
17
- return;
18
- }
19
-
20
- let array = [];
21
-
22
- /**
23
- *
24
- */
25
- function cleanup() {
26
- array = null;
27
-
28
- // eslint-disable-next-line no-use-before-define
29
- stream.removeListener("data", onData);
30
- // eslint-disable-next-line no-use-before-define
31
- stream.removeListener("end", onEnd);
32
- // eslint-disable-next-line no-use-before-define
33
- stream.removeListener("error", onError);
34
- // eslint-disable-next-line no-use-before-define
35
- stream.removeListener("close", onClose);
36
- }
37
-
38
- /**
39
- *
40
- * @param document_
41
- */
42
- function onData(document_) {
43
- array.push(document_);
44
- }
45
-
46
- /**
47
- *
48
- */
49
- function onEnd() {
50
- resolve(array);
51
- cleanup();
52
- }
53
-
54
- /**
55
- *
56
- * @param error
57
- */
58
- function onError(error) {
59
- reject(error);
60
- cleanup();
61
- }
62
-
63
- /**
64
- *
65
- */
66
- function onClose() {
67
- resolve(array);
68
- cleanup();
69
- }
70
-
71
- stream.on("data", onData);
72
- stream.on("end", onEnd);
73
- stream.on("error", onEnd);
74
- stream.on("close", onClose);
75
- });
76
- }