@storm-software/workspace-tools 1.159.0 → 1.159.1

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.
@@ -0,0 +1,3 @@
1
+ import { CargoBaseExecutorSchema } from "../../../declarations";
2
+
3
+ export type CargoFormatExecutorSchema = CargoBaseExecutorSchema;
@@ -0,0 +1,134 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "cargo-format",
4
+ "outputCapture": "direct-nodejs",
5
+ "version": 2,
6
+ "title": "Cargo Format",
7
+ "description": "Format a Rust project with Cargo",
8
+ "type": "object",
9
+ "properties": {
10
+ "release": {
11
+ "type": "boolean",
12
+ "description": "Run the Cargo command for the project in release mode",
13
+ "default": false
14
+ },
15
+ "profile": {
16
+ "type": "string",
17
+ "description": "Build artifacts with the specified profile"
18
+ },
19
+ "toolchain": {
20
+ "type": "string",
21
+ "description": "The Rust toolchain to use",
22
+ "enum": ["stable", "beta", "nightly"],
23
+ "default": "stable"
24
+ },
25
+ "features": {
26
+ "oneOf": [
27
+ {
28
+ "type": "string"
29
+ },
30
+ {
31
+ "type": "array",
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ }
36
+ ],
37
+ "description": "Features of workspace members may be enabled with package-name/feature-name syntax. Array of names is supported"
38
+ },
39
+ "allFeatures": {
40
+ "type": "boolean",
41
+ "default": false,
42
+ "description": "Build all binary targets",
43
+ "alias": "all-features"
44
+ },
45
+ "lib": {
46
+ "type": "boolean",
47
+ "description": "Build the package's library",
48
+ "default": false
49
+ },
50
+ "bin": {
51
+ "oneOf": [
52
+ {
53
+ "type": "string"
54
+ },
55
+ {
56
+ "type": "array",
57
+ "items": {
58
+ "type": "string"
59
+ }
60
+ }
61
+ ],
62
+ "description": "Build the specified binary. Array of names or common Unix glob patterns is supported"
63
+ },
64
+ "bins": {
65
+ "type": "boolean",
66
+ "default": false,
67
+ "description": "Build all binary targets"
68
+ },
69
+ "example": {
70
+ "oneOf": [
71
+ {
72
+ "type": "string"
73
+ },
74
+ {
75
+ "type": "array",
76
+ "items": {
77
+ "type": "string"
78
+ }
79
+ }
80
+ ],
81
+ "description": "Build the specified example. Array of names or common Unix glob patterns is supported"
82
+ },
83
+ "examples": {
84
+ "type": "boolean",
85
+ "default": false,
86
+ "description": "Build all example targets"
87
+ },
88
+ "test": {
89
+ "oneOf": [
90
+ {
91
+ "type": "string"
92
+ },
93
+ {
94
+ "type": "array",
95
+ "items": {
96
+ "type": "string"
97
+ }
98
+ }
99
+ ],
100
+ "description": "Build the specified test. Array of names or common Unix glob patterns is supported"
101
+ },
102
+ "tests": {
103
+ "type": "boolean",
104
+ "default": false,
105
+ "description": "Build all test targets"
106
+ },
107
+ "bench": {
108
+ "oneOf": [
109
+ {
110
+ "type": "string"
111
+ },
112
+ {
113
+ "type": "array",
114
+ "items": {
115
+ "type": "string"
116
+ }
117
+ }
118
+ ],
119
+ "description": "Build the specified bench. Array of names or common Unix glob patterns is supported"
120
+ },
121
+ "benches": {
122
+ "type": "boolean",
123
+ "default": false,
124
+ "description": "Build all targets in benchmark mode that have the bench = true manifest flag set. By default this includes the library and binaries built as benchmarks, and bench targets. Be aware that this will also build any required dependencies, so the lib target may be built twice (once as a benchmark, and once as a dependency for binaries, benchmarks, etc.). Targets may be enabled or disabled by setting the bench flag in the manifest settings for the target."
125
+ },
126
+ "allTargets": {
127
+ "type": "boolean",
128
+ "default": false,
129
+ "description": "Build all test targets",
130
+ "alias": "all-targets"
131
+ }
132
+ },
133
+ "required": []
134
+ }
@@ -1,8 +1,19 @@
1
1
  import { type CreateDependencies, type CreateNodes } from "@nx/devkit";
2
2
  export declare const name = "storm-software/rust/cargo-toml";
3
+ export declare const description = "Plugin for parsing Cargo.toml files";
4
+ export type CargoPluginProfileMap = Record<string, string> & {
5
+ development?: string;
6
+ production?: string;
7
+ };
8
+ export declare const DefaultCargoPluginProfileMap: {
9
+ development: string;
10
+ production: string;
11
+ };
3
12
  export interface CargoPluginOptions {
4
13
  includeApps?: boolean;
5
14
  skipDocs?: boolean;
15
+ toolchain?: "stable" | "beta" | "nightly";
16
+ profiles?: CargoPluginProfileMap;
6
17
  }
7
18
  export declare const createNodes: CreateNodes<CargoPluginOptions>;
8
19
  export declare const createDependencies: CreateDependencies;
@@ -19,8 +19,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // packages/workspace-tools/src/plugins/rust/index.ts
20
20
  var rust_exports = {};
21
21
  __export(rust_exports, {
22
+ DefaultCargoPluginProfileMap: () => DefaultCargoPluginProfileMap,
22
23
  createDependencies: () => createDependencies,
23
24
  createNodes: () => createNodes,
25
+ description: () => description,
24
26
  name: () => name
25
27
  });
26
28
  module.exports = __toCommonJS(rust_exports);
@@ -137,9 +139,18 @@ var setDefaultProjectTags = (project) => {
137
139
 
138
140
  // packages/workspace-tools/src/plugins/rust/cargo-toml.ts
139
141
  var name = "storm-software/rust/cargo-toml";
142
+ var description = "Plugin for parsing Cargo.toml files";
143
+ var DefaultCargoPluginProfileMap = {
144
+ development: "dev",
145
+ production: "prod"
146
+ };
140
147
  var createNodes = [
141
148
  "*/**/Cargo.toml",
142
- (cargoFile, opts = { includeApps: true, skipDocs: false }, ctx) => {
149
+ (cargoFile, opts = {
150
+ includeApps: true,
151
+ skipDocs: false,
152
+ profiles: {}
153
+ }, ctx) => {
143
154
  const metadata = cargoMetadata();
144
155
  if (!metadata) {
145
156
  return {};
@@ -147,6 +158,16 @@ var createNodes = [
147
158
  const { packages: cargoPackages } = metadata;
148
159
  const externalNodes = {};
149
160
  const projects = {};
161
+ const profiles = {
162
+ ...DefaultCargoPluginProfileMap,
163
+ ...opts.profiles
164
+ };
165
+ const configurations = Object.keys(profiles).reduce((ret, key) => {
166
+ ret[key] = {
167
+ profile: profiles[key]
168
+ };
169
+ return ret;
170
+ }, {});
150
171
  const cargoPackageMap = cargoPackages.reduce((acc, p) => {
151
172
  if (!acc.has(p.name)) {
152
173
  acc.set(p.name, p);
@@ -188,11 +209,25 @@ var createNodes = [
188
209
  lint: {
189
210
  cache: true,
190
211
  inputs: ["linting", "rust", "^production"],
191
- dependsOn: ["lint-ls", "^lint"],
192
- executor: "@monodon/rust:lint",
212
+ dependsOn: ["^lint"],
213
+ executor: "@storm-software/workspace-tools:cargo-clippy",
193
214
  options: {
194
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
195
- }
215
+ toolchain: opts.toolchain,
216
+ fix: false
217
+ },
218
+ defaultConfiguration: "development",
219
+ configurations
220
+ },
221
+ check: {
222
+ cache: true,
223
+ inputs: ["linting", "rust", "^production"],
224
+ dependsOn: ["lint", "^check"],
225
+ executor: "@storm-software/workspace-tools:cargo-check",
226
+ options: {
227
+ toolchain: opts.toolchain
228
+ },
229
+ defaultConfiguration: "development",
230
+ configurations
196
231
  },
197
232
  "format-readme": {
198
233
  cache: true,
@@ -204,23 +239,42 @@ var createNodes = [
204
239
  inputs: ["linting", "rust", "^production"],
205
240
  dependsOn: ["^format-toml"]
206
241
  },
242
+ "format-clippy": {
243
+ cache: true,
244
+ inputs: ["linting", "rust", "^production"],
245
+ dependsOn: ["^format-clippy"],
246
+ executor: "@storm-software/workspace-tools:cargo-clippy",
247
+ options: {
248
+ toolchain: opts.toolchain,
249
+ fix: true
250
+ },
251
+ defaultConfiguration: "development",
252
+ configurations
253
+ },
207
254
  format: {
208
255
  cache: true,
209
256
  inputs: ["linting", "documentation", "rust", "^production"],
210
- dependsOn: ["format-readme", "format-toml", "^format"],
211
- executor: "nx:run-commands",
257
+ dependsOn: [
258
+ "format-readme",
259
+ "format-clippy",
260
+ "format-toml",
261
+ "^format"
262
+ ],
263
+ executor: "@storm-software/workspace-tools:cargo-format",
212
264
  options: {
213
- command: `cargo fmt -p ${project.name}`,
214
- color: true
215
- }
265
+ toolchain: opts.toolchain,
266
+ fix: true
267
+ },
268
+ defaultConfiguration: "development",
269
+ configurations
216
270
  },
217
271
  clean: {
218
272
  cache: true,
219
273
  inputs: ["rust", "^production"],
220
- outputs: [`{workspaceRoot}/dist/target/${cargoPackage.name}`],
274
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
221
275
  executor: "nx:run-commands",
222
276
  options: {
223
- command: `pnpm exec rimraf dist/target/${cargoPackage.name}`,
277
+ command: `pnpm exec rimraf dist/target/crates/${cargoPackage.name}`,
224
278
  color: true,
225
279
  cwd: "{workspaceRoot}"
226
280
  }
@@ -229,21 +283,25 @@ var createNodes = [
229
283
  cache: true,
230
284
  inputs: ["rust", "^production"],
231
285
  dependsOn: ["build-base", "^build"],
232
- executor: "@monodon/rust:check",
233
- outputs: ["{options.target-dir}"],
286
+ executor: "@storm-software/workspace-tools:cargo-build",
287
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
234
288
  options: {
235
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
236
- }
289
+ toolchain: opts.toolchain
290
+ },
291
+ defaultConfiguration: "development",
292
+ configurations
237
293
  },
238
294
  rebuild: {
239
295
  cache: false,
240
296
  inputs: ["rust", "^production"],
241
297
  dependsOn: ["clean", "^build"],
242
- executor: "@monodon/rust:check",
243
- outputs: ["{options.target-dir}"],
298
+ executor: "@storm-software/workspace-tools:cargo-build",
299
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
244
300
  options: {
245
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
246
- }
301
+ toolchain: opts.toolchain
302
+ },
303
+ defaultConfiguration: "development",
304
+ configurations
247
305
  },
248
306
  test: {
249
307
  cache: true,
@@ -252,26 +310,24 @@ var createNodes = [
252
310
  executor: "@monodon/rust:test",
253
311
  outputs: ["{options.target-dir}"],
254
312
  options: {
255
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
313
+ "target-dir": `{workspaceRoot}/dist/target/{projectRoot}`
256
314
  },
257
- configurations: {
258
- production: {
259
- release: true
260
- }
261
- }
315
+ defaultConfiguration: "development",
316
+ configurations
262
317
  }
263
318
  };
264
319
  if (opts.skipDocs != true) {
265
320
  project.targets.docs = {
266
321
  cache: true,
267
322
  inputs: ["linting", "documentation", "default", "^production"],
268
- dependsOn: ["build", "lint-docs", "^docs"],
269
- outputs: [`{workspaceRoot}/dist/docs/${cargoPackage.name}`],
270
- executor: "nx:run-commands",
323
+ dependsOn: ["build", "format-readme", "lint-docs", "^docs"],
324
+ outputs: [`{workspaceRoot}/dist/docs/{projectRoot}`],
325
+ executor: "@storm-software/workspace-tools:cargo-doc",
271
326
  options: {
272
- command: `cargo doc -p ${project.name} --target-dir dist/docs/${cargoPackage.name}`,
273
- color: true
274
- }
327
+ toolchain: opts.toolchain
328
+ },
329
+ defaultConfiguration: "development",
330
+ configurations
275
331
  };
276
332
  }
277
333
  if (cargoPackage.publish === null || cargoPackage.publish === void 0 || cargoPackage.publish === true || Array.isArray(cargoPackage.publish) && cargoPackage.publish.length > 0) {
@@ -284,10 +340,13 @@ var createNodes = [
284
340
  "rust",
285
341
  "^production"
286
342
  ],
343
+ dependsOn: ["build", "^nx-release-publish"],
287
344
  executor: "@storm-software/workspace-tools:cargo-publish",
288
345
  options: {
289
346
  packageRoot: root
290
- }
347
+ },
348
+ defaultConfiguration: "development",
349
+ configurations
291
350
  };
292
351
  }
293
352
  addProjectTag(
@@ -372,7 +431,9 @@ function createDependency(pkg, depName, type) {
372
431
  }
373
432
  // Annotate the CommonJS export names for ESM import in node:
374
433
  0 && (module.exports = {
434
+ DefaultCargoPluginProfileMap,
375
435
  createDependencies,
376
436
  createNodes,
437
+ description,
377
438
  name
378
439
  });
@@ -1,4 +1,6 @@
1
+ import { ExecutorContext } from "@nx/devkit";
1
2
  import { type ChildProcess, type StdioOptions } from "node:child_process";
3
+ import { CargoBaseExecutorSchema } from "../../declarations.d";
2
4
  import type { CargoMetadata, Dependency, Package } from "./toml";
3
5
  interface CargoRun {
4
6
  success: boolean;
@@ -8,7 +10,9 @@ interface RunCargoOptions {
8
10
  stdio: StdioOptions;
9
11
  env: NodeJS.ProcessEnv | undefined;
10
12
  }
13
+ export declare const INVALID_CARGO_ARGS: string[];
11
14
  export declare let childProcess: ChildProcess | null;
15
+ export declare const buildCargoCommand: (baseCommand: string, options: CargoBaseExecutorSchema, context: ExecutorContext) => string[];
12
16
  export declare function cargoCommand(...args: string[]): Promise<{
13
17
  success: boolean;
14
18
  }>;
@@ -298964,6 +298964,7 @@ var require_transform = __commonJS({
298964
298964
  // packages/workspace-tools/src/utils/index.ts
298965
298965
  var utils_exports = {};
298966
298966
  __export(utils_exports, {
298967
+ INVALID_CARGO_ARGS: () => INVALID_CARGO_ARGS,
298967
298968
  LOCK_FILES: () => LOCK_FILES,
298968
298969
  NPM_LOCK_FILE: () => NPM_LOCK_FILE,
298969
298970
  NPM_LOCK_PATH: () => NPM_LOCK_PATH,
@@ -298974,6 +298975,7 @@ __export(utils_exports, {
298974
298975
  YARN_LOCK_PATH: () => YARN_LOCK_PATH,
298975
298976
  addProjectTag: () => addProjectTag,
298976
298977
  applyWorkspaceExecutorTokens: () => applyWorkspaceExecutorTokens,
298978
+ buildCargoCommand: () => buildCargoCommand,
298977
298979
  cargoCommand: () => cargoCommand,
298978
298980
  cargoCommandSync: () => cargoCommandSync,
298979
298981
  cargoMetadata: () => cargoMetadata,
@@ -299080,7 +299082,53 @@ var applyWorkspaceExecutorTokens = async (option, tokenizerOptions) => {
299080
299082
  var import_devkit = require("@nx/devkit");
299081
299083
  var import_node_child_process6 = require("node:child_process");
299082
299084
  var import_node_path8 = require("node:path");
299085
+ var INVALID_CARGO_ARGS = [
299086
+ "allFeatures",
299087
+ "allTargets",
299088
+ "main",
299089
+ "outputPath",
299090
+ "tsConfig"
299091
+ ];
299083
299092
  var childProcess2;
299093
+ var buildCargoCommand = (baseCommand, options, context) => {
299094
+ const args = [];
299095
+ if (options.toolchain && options.toolchain !== "stable") {
299096
+ args.push(`+${options.toolchain}`);
299097
+ }
299098
+ args.push(baseCommand);
299099
+ for (const [key, value2] of Object.entries(options)) {
299100
+ if (key === "toolchain" || key === "release" || INVALID_CARGO_ARGS.includes(key)) {
299101
+ continue;
299102
+ }
299103
+ if (typeof value2 === "boolean") {
299104
+ if (value2) {
299105
+ args.push(`--${key}`);
299106
+ }
299107
+ } else if (Array.isArray(value2)) {
299108
+ for (const item of value2) {
299109
+ args.push(`--${key}`, item);
299110
+ }
299111
+ } else {
299112
+ args.push(`--${key}`, value2);
299113
+ }
299114
+ }
299115
+ if (options.allFeatures && !args.includes("--all-features")) {
299116
+ args.push("--all-features");
299117
+ }
299118
+ if (options.allTargets && !args.includes("--all-targets")) {
299119
+ args.push("--all-targets");
299120
+ }
299121
+ if (options.release && !args.includes("--profile")) {
299122
+ args.push("--release");
299123
+ }
299124
+ if (context.projectName && !args.includes("--package")) {
299125
+ args.push("-p", context.projectName);
299126
+ }
299127
+ if (options.outputPath && !args.includes("--target-dir")) {
299128
+ args.push("--target-dir", options.outputPath);
299129
+ }
299130
+ return args;
299131
+ };
299084
299132
  async function cargoCommand(...args) {
299085
299133
  console.log(`> cargo ${args.join(" ")}`);
299086
299134
  args.push("--color", "always");
@@ -302317,6 +302365,7 @@ var nodeVersion = "20.11.0";
302317
302365
  var pnpmVersion = "8.10.2";
302318
302366
  // Annotate the CommonJS export names for ESM import in node:
302319
302367
  0 && (module.exports = {
302368
+ INVALID_CARGO_ARGS,
302320
302369
  LOCK_FILES,
302321
302370
  NPM_LOCK_FILE,
302322
302371
  NPM_LOCK_PATH,
@@ -302327,6 +302376,7 @@ var pnpmVersion = "8.10.2";
302327
302376
  YARN_LOCK_PATH,
302328
302377
  addProjectTag,
302329
302378
  applyWorkspaceExecutorTokens,
302379
+ buildCargoCommand,
302330
302380
  cargoCommand,
302331
302381
  cargoCommandSync,
302332
302382
  cargoMetadata,