@storm-software/workspace-tools 1.66.9 → 1.66.11
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 +24 -0
- package/package.json +2 -1
- package/src/executors/cargo-publish/executor.ts +28 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 1.66.11 (2024-03-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🩹 Fixes
|
|
5
|
+
|
|
6
|
+
- **workspace-tools:** Enhance code to check crates.io version through API ([1cec1ccd](https://github.com/storm-software/storm-ops/commit/1cec1ccd))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- Patrick Sullivan
|
|
12
|
+
|
|
13
|
+
## 1.66.10 (2024-03-28)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 🩹 Fixes
|
|
17
|
+
|
|
18
|
+
- **workspace-tools:** Add logic to get current version from crates.io during publish ([0e70268c](https://github.com/storm-software/storm-ops/commit/0e70268c))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- Patrick Sullivan
|
|
24
|
+
|
|
1
25
|
## 1.66.9 (2024-03-28)
|
|
2
26
|
|
|
3
27
|
|
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.11",
|
|
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": [
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@nx/devkit": "18.0.4",
|
|
53
53
|
"@nx/esbuild": "18.0.4",
|
|
54
54
|
"@rollup/plugin-json": "6.1.0",
|
|
55
|
+
"axios": "1.6.7",
|
|
55
56
|
"bundle-require": "^4.0.2",
|
|
56
57
|
"decky": "1.1.1",
|
|
57
58
|
"esbuild-plugin-environment": "0.3.0",
|
|
@@ -1,12 +1,19 @@
|
|
|
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 axios from "axios";
|
|
7
|
+
import { encode } from "node:querystring";
|
|
6
8
|
|
|
7
9
|
const LARGE_BUFFER = 1024 * 1000000;
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const REGISTRY = axios.create({
|
|
12
|
+
baseURL: "https://crates.io/api/v1/crates",
|
|
13
|
+
headers: { "Content-Type": "application/json", Authorization: process.env.CARGO_REGISTRY_TOKEN },
|
|
14
|
+
timeout: 8000
|
|
15
|
+
});
|
|
16
|
+
|
|
10
17
|
export default async function runExecutor(
|
|
11
18
|
options: CargoPublishExecutorSchema,
|
|
12
19
|
context: ExecutorContext
|
|
@@ -40,6 +47,21 @@ export default async function runExecutor(
|
|
|
40
47
|
readFileSync(joinPathFragments(packageRoot, "Cargo.toml"), "utf-8")
|
|
41
48
|
);
|
|
42
49
|
|
|
50
|
+
try {
|
|
51
|
+
const result = await REGISTRY.get(
|
|
52
|
+
`/${encode(cargoToml.package.name)}/${encode(cargoToml.package.version)}`
|
|
53
|
+
);
|
|
54
|
+
if (result?.data) {
|
|
55
|
+
console.warn(
|
|
56
|
+
`Skipped package "${cargoToml.package.name}" from project "${context.projectName}" because v${cargoToml.package.version} already exists in https://crates.io with tag "latest"`
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
success: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
} catch (_: any) {}
|
|
64
|
+
|
|
43
65
|
const cargoPublishCommandSegments = [`cargo publish --allow-dirty -p ${cargoToml.package.name}`];
|
|
44
66
|
if (isDryRun) {
|
|
45
67
|
cargoPublishCommandSegments.push("--dry-run");
|
|
@@ -47,9 +69,11 @@ export default async function runExecutor(
|
|
|
47
69
|
|
|
48
70
|
try {
|
|
49
71
|
const command = cargoPublishCommandSegments.join(" ");
|
|
50
|
-
|
|
72
|
+
console.log("");
|
|
73
|
+
console.log(`Running "${command}"...`);
|
|
74
|
+
console.log("");
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
execSync(command, {
|
|
53
77
|
maxBuffer: LARGE_BUFFER,
|
|
54
78
|
env: {
|
|
55
79
|
...process.env,
|
|
@@ -59,27 +83,6 @@ export default async function runExecutor(
|
|
|
59
83
|
stdio: ["ignore", "pipe", "pipe"]
|
|
60
84
|
});
|
|
61
85
|
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
86
|
|
|
84
87
|
if (isDryRun) {
|
|
85
88
|
console.log("Would publish to https://crates.io, but [dry-run] was set");
|
|
@@ -100,19 +103,3 @@ export default async function runExecutor(
|
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
}
|
|
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);
|