@tymonmarek/wally 0.2.5 → 0.3.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.
- package/build/args.js +7 -0
- package/build/config.js +2 -0
- package/build/error.js +16 -1
- package/build/index.js +17 -0
- package/build/package.js +36 -0
- package/build/verify.js +19 -0
- package/package.json +5 -2
package/build/args.js
ADDED
package/build/config.js
ADDED
package/build/error.js
CHANGED
|
@@ -12,11 +12,26 @@ exports.link = link;
|
|
|
12
12
|
var ErrorCode;
|
|
13
13
|
(function (ErrorCode) {
|
|
14
14
|
ErrorCode[ErrorCode["WallyNotInstalled"] = 0] = "WallyNotInstalled";
|
|
15
|
+
ErrorCode[ErrorCode["WallyTokenMissing"] = 1] = "WallyTokenMissing";
|
|
16
|
+
ErrorCode[ErrorCode["WallyPackageNameMissing"] = 2] = "WallyPackageNameMissing";
|
|
17
|
+
ErrorCode[ErrorCode["WallyPackageMissing"] = 3] = "WallyPackageMissing";
|
|
15
18
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
16
19
|
exports.ERROR_DEFINITIONS = {
|
|
17
20
|
[ErrorCode.WallyNotInstalled]: {
|
|
18
21
|
message: "Wally is not installed.",
|
|
19
|
-
details: `Wally must be installed to use this plugin
|
|
22
|
+
details: `Wally must be installed to use this plugin.\n\nPlease install Wally by following the instructions at ${(0, exports.link)("README.md#installation")}.`,
|
|
23
|
+
},
|
|
24
|
+
[ErrorCode.WallyTokenMissing]: {
|
|
25
|
+
message: "Wally token is missing.",
|
|
26
|
+
details: `A Wally token is required to use this plugin.\n\nPlease provide a valid Wally token by following the instructions at ${(0, exports.link)("README.md#configuration")}.`,
|
|
27
|
+
},
|
|
28
|
+
[ErrorCode.WallyPackageNameMissing]: {
|
|
29
|
+
message: "Wally package name is missing.",
|
|
30
|
+
details: `The package name is required in the wally.toml file.\n\nPlease provide a valid package name by following the instructions at ${(0, exports.link)("README.md#configuration")}.`,
|
|
31
|
+
},
|
|
32
|
+
[ErrorCode.WallyPackageMissing]: {
|
|
33
|
+
message: "Wally package file is missing.",
|
|
34
|
+
details: `The wally.toml file is required to use this plugin.\n\nPlease create a wally.toml file by following the instructions at ${(0, exports.link)("README.md#configuration")}.`,
|
|
20
35
|
},
|
|
21
36
|
};
|
|
22
37
|
function getError(errorCode) {
|
package/build/index.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyConditions = verifyConditions;
|
|
4
|
+
const verify_1 = require("./verify");
|
|
5
|
+
const package_1 = require("./package");
|
|
6
|
+
async function verifyConditions(pluginConfig, context) {
|
|
7
|
+
const errors = await (0, verify_1.verifyWally)(pluginConfig, context);
|
|
8
|
+
try {
|
|
9
|
+
await (0, package_1.getWallyPackage)(pluginConfig, context);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error instanceof Error) {
|
|
13
|
+
errors.push(...errors);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (errors.length > 0) {
|
|
17
|
+
throw new AggregateError(errors);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/build/package.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readWallyPackage = readWallyPackage;
|
|
7
|
+
exports.getWallyPackage = getWallyPackage;
|
|
8
|
+
const toml_1 = __importDefault(require("toml"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
|
+
const error_1 = require("./error");
|
|
12
|
+
const aggregate_error_1 = __importDefault(require("aggregate-error"));
|
|
13
|
+
async function readWallyPackage(_, context) {
|
|
14
|
+
const wallyPackagePath = path_1.default.join(context.cwd ?? process.cwd(), "wally.toml");
|
|
15
|
+
const wallyPackageContent = await promises_1.default.readFile(wallyPackagePath, "utf-8");
|
|
16
|
+
const wallyPackage = toml_1.default.parse(wallyPackageContent);
|
|
17
|
+
return wallyPackage;
|
|
18
|
+
}
|
|
19
|
+
async function getWallyPackage(pluginConfig, context) {
|
|
20
|
+
try {
|
|
21
|
+
const wallyPackage = await readWallyPackage(pluginConfig, context);
|
|
22
|
+
if (!wallyPackage.package.name) {
|
|
23
|
+
throw (0, error_1.getError)(error_1.ErrorCode.WallyPackageNameMissing);
|
|
24
|
+
}
|
|
25
|
+
return wallyPackage;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code === "ENOENT") {
|
|
29
|
+
throw new aggregate_error_1.default([(0, error_1.getError)(error_1.ErrorCode.WallyPackageMissing)]);
|
|
30
|
+
}
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
throw new aggregate_error_1.default([error]);
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/build/verify.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyWally = verifyWally;
|
|
4
|
+
const args_1 = require("./args");
|
|
5
|
+
const error_1 = require("./error");
|
|
6
|
+
const execa_1 = require("execa");
|
|
7
|
+
async function verifyWally(pluginConfig, context) {
|
|
8
|
+
const errors = [];
|
|
9
|
+
const { wallyToken } = (0, args_1.parsePluginArgs)(pluginConfig, context);
|
|
10
|
+
if (!wallyToken) {
|
|
11
|
+
errors.push((0, error_1.getError)(error_1.ErrorCode.WallyTokenMissing));
|
|
12
|
+
}
|
|
13
|
+
const { cwd, env } = context;
|
|
14
|
+
if ((await (0, execa_1.execa)("wally", ["--version"], { reject: false, cwd, env }))
|
|
15
|
+
.exitCode !== 0) {
|
|
16
|
+
errors.push((0, error_1.getError)(error_1.ErrorCode.WallyNotInstalled));
|
|
17
|
+
}
|
|
18
|
+
return errors;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tymonmarek/wally",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A minimal plugin template for semantic-release.",
|
|
5
5
|
"homepage": "https://github.com/TymonMarek/wally",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -60,6 +60,9 @@
|
|
|
60
60
|
"typescript-eslint": "^8.54.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"
|
|
63
|
+
"aggregate-error": "^5.0.0",
|
|
64
|
+
"execa": "^9.6.1",
|
|
65
|
+
"semantic-release": "^25.0.3",
|
|
66
|
+
"toml": "^3.0.0"
|
|
64
67
|
}
|
|
65
68
|
}
|