@storm-software/workspace-tools 1.66.8 → 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 CHANGED
@@ -1,3 +1,27 @@
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
+
13
+ ## 1.66.9 (2024-03-28)
14
+
15
+
16
+ ### 🩹 Fixes
17
+
18
+ - **workspace-tools:** Resolve result handling in `cargo-publish` executor ([09a25a73](https://github.com/storm-software/storm-ops/commit/09a25a73))
19
+
20
+
21
+ ### ❤️ Thank You
22
+
23
+ - Patrick Sullivan
24
+
1
25
  ## 1.66.8 (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.8",
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, output } from "@nx/devkit";
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,15 +66,18 @@ export default async function runExecutor(
47
66
 
48
67
  try {
49
68
  const command = cargoPublishCommandSegments.join(" ");
50
- output.logSingleLine(`Running "${command}"...`);
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
- ...process.env
76
+ ...process.env,
77
+ FORCE_COLOR: "true"
56
78
  },
57
79
  cwd: packageRoot,
58
- stdio: "inherit"
80
+ stdio: ["ignore", "pipe", "pipe"]
59
81
  });
60
82
  console.log("");
61
83
 
@@ -69,48 +91,12 @@ export default async function runExecutor(
69
91
  success: true
70
92
  };
71
93
  } catch (error: any) {
72
- if (
73
- (error?.message &&
74
- typeof error.message === "string" &&
75
- error.message.toLowerCase().includes("crate version") &&
76
- error.message.toLowerCase().includes("is already uploaded")) ||
77
- (error?.cause?.message &&
78
- typeof error.cause.message === "string" &&
79
- error.cause.message.toLowerCase().includes("crate version") &&
80
- error.cause.message.toLowerCase().includes("is already uploaded"))
81
- ) {
82
- console.log(
83
- `Skipped package "${cargoToml.package.name}" from project "${cargoToml.package.name}" because v${cargoToml.package.version} already exists in https://crates.io with tag "latest"`
84
- );
85
-
86
- return {
87
- success: true
88
- };
89
- }
90
-
91
94
  console.error("Failed to publish to https://crates.io");
92
95
  console.error(error);
93
96
  console.log("");
94
- console.error(formatLog(error));
95
97
 
96
98
  return {
97
99
  success: false
98
100
  };
99
101
  }
100
102
  }
101
-
102
- const formatLog = (message?: any, name?: string): string =>
103
- typeof message === "boolean"
104
- ? String(message)
105
- : !message
106
- ? "<None>"
107
- : typeof message === "string"
108
- ? `"${message}"`
109
- : typeof message === "number"
110
- ? message.toString()
111
- : typeof message === "object"
112
- ? (name ? ` --- ${name} ---\n` : "") +
113
- Object.keys(message)
114
- .map((key) => ` - ${key}=${formatLog(message[key])}`)
115
- .join("\n")
116
- : JSON.stringify(message);