@storm-software/workspace-tools 1.66.9 → 1.66.10
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/CHANGELOG.md +12 -0
- package/package.json +2 -1
- package/src/executors/cargo-publish/executor.ts +25 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 1.66.10 (2024-03-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🩹 Fixes
|
|
5
|
+
|
|
6
|
+
- **workspace-tools:** Add logic to get current version from crates.io during publish ([0e70268c](https://github.com/storm-software/storm-ops/commit/0e70268c))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- Patrick Sullivan
|
|
12
|
+
|
|
1
13
|
## 1.66.9 (2024-03-28)
|
|
2
14
|
|
|
3
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/workspace-tools",
|
|
3
|
-
"version": "1.66.
|
|
3
|
+
"version": "1.66.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "⚡ A Nx plugin package that contains various executors and generators used in a Storm workspaces.",
|
|
6
6
|
"keywords": [
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@nx/esbuild": "18.0.4",
|
|
54
54
|
"@rollup/plugin-json": "6.1.0",
|
|
55
55
|
"bundle-require": "^4.0.2",
|
|
56
|
+
"crates.io": "^2.2.7",
|
|
56
57
|
"decky": "1.1.1",
|
|
57
58
|
"esbuild-plugin-environment": "0.3.0",
|
|
58
59
|
"esbuild-plugin-handlebars": "1.0.2",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type ExecutorContext, joinPathFragments
|
|
1
|
+
import { type ExecutorContext, joinPathFragments } from "@nx/devkit";
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { parseCargoToml } from "../../utils/toml";
|
|
5
5
|
import type { CargoPublishExecutorSchema } from "./schema.d";
|
|
6
|
+
import { CratesIO } from "crates.io";
|
|
6
7
|
|
|
7
8
|
const LARGE_BUFFER = 1024 * 1000000;
|
|
8
9
|
|
|
9
|
-
// biome-ignore lint/nursery/useAwait: <explanation>
|
|
10
10
|
export default async function runExecutor(
|
|
11
11
|
options: CargoPublishExecutorSchema,
|
|
12
12
|
context: ExecutorContext
|
|
@@ -40,6 +40,25 @@ export default async function runExecutor(
|
|
|
40
40
|
readFileSync(joinPathFragments(packageRoot, "Cargo.toml"), "utf-8")
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
+
try {
|
|
44
|
+
const currentVersion = cargoToml.package.version;
|
|
45
|
+
const packageName = cargoToml.package.name;
|
|
46
|
+
|
|
47
|
+
const result = await new CratesIO().api.crates.getVersion(packageName, currentVersion);
|
|
48
|
+
if (result) {
|
|
49
|
+
console.warn(
|
|
50
|
+
`Skipped package "${packageName}" from project "${context.projectName}" because v${currentVersion} already exists in https://crates.io with tag "latest"`
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
success: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
} catch (error: any) {
|
|
58
|
+
console.log("No results returned while checking the crate version in https://crates.io");
|
|
59
|
+
console.warn(error);
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
const cargoPublishCommandSegments = [`cargo publish --allow-dirty -p ${cargoToml.package.name}`];
|
|
44
63
|
if (isDryRun) {
|
|
45
64
|
cargoPublishCommandSegments.push("--dry-run");
|
|
@@ -47,9 +66,11 @@ export default async function runExecutor(
|
|
|
47
66
|
|
|
48
67
|
try {
|
|
49
68
|
const command = cargoPublishCommandSegments.join(" ");
|
|
50
|
-
|
|
69
|
+
console.log("");
|
|
70
|
+
console.log(`Running "${command}"...`);
|
|
71
|
+
console.log("");
|
|
51
72
|
|
|
52
|
-
|
|
73
|
+
execSync(command, {
|
|
53
74
|
maxBuffer: LARGE_BUFFER,
|
|
54
75
|
env: {
|
|
55
76
|
...process.env,
|
|
@@ -59,27 +80,6 @@ export default async function runExecutor(
|
|
|
59
80
|
stdio: ["ignore", "pipe", "pipe"]
|
|
60
81
|
});
|
|
61
82
|
console.log("");
|
|
62
|
-
console.log(result ? result.toString() : "No Result");
|
|
63
|
-
|
|
64
|
-
const resultJson = JSON.parse(result.toString());
|
|
65
|
-
if (
|
|
66
|
-
(resultJson?.message &&
|
|
67
|
-
typeof resultJson.message === "string" &&
|
|
68
|
-
resultJson.message.toLowerCase().includes("crate version") &&
|
|
69
|
-
resultJson.message.toLowerCase().includes("is already uploaded")) ||
|
|
70
|
-
(resultJson?.cause?.message &&
|
|
71
|
-
typeof resultJson.cause.message === "string" &&
|
|
72
|
-
resultJson.cause.message.toLowerCase().includes("crate version") &&
|
|
73
|
-
resultJson.cause.message.toLowerCase().includes("is already uploaded"))
|
|
74
|
-
) {
|
|
75
|
-
console.warn(
|
|
76
|
-
`Skipped package "${cargoToml.package.name}" from project "${cargoToml.package.name}" because v${cargoToml.package.version} already exists in https://crates.io with tag "latest"`
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
success: true
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
83
|
|
|
84
84
|
if (isDryRun) {
|
|
85
85
|
console.log("Would publish to https://crates.io, but [dry-run] was set");
|
|
@@ -100,19 +100,3 @@ export default async function runExecutor(
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
const formatLog = (message?: any, name?: string): string =>
|
|
105
|
-
typeof message === "boolean"
|
|
106
|
-
? String(message)
|
|
107
|
-
: !message
|
|
108
|
-
? "<None>"
|
|
109
|
-
: typeof message === "string"
|
|
110
|
-
? `"${message}"`
|
|
111
|
-
: typeof message === "number"
|
|
112
|
-
? message.toString()
|
|
113
|
-
: typeof message === "object"
|
|
114
|
-
? (name ? ` --- ${name} ---\n` : "") +
|
|
115
|
-
Object.keys(message)
|
|
116
|
-
.map((key) => ` - ${key}=${formatLog(message[key], key)}`)
|
|
117
|
-
.join("\n")
|
|
118
|
-
: JSON.stringify(message);
|