@storm-software/workspace-tools 1.158.1 → 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.
Files changed (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +278 -69
  3. package/config/nx.json +2 -2
  4. package/declarations.d.ts +15 -4
  5. package/executors.json +35 -10
  6. package/index.js +50 -0
  7. package/meta.json +1 -1
  8. package/package.json +1 -1
  9. package/src/executors/cargo-build/executor.d.ts +7 -0
  10. package/src/executors/cargo-build/executor.js +68635 -0
  11. package/src/executors/cargo-build/schema.d.ts +3 -0
  12. package/src/executors/cargo-build/schema.json +138 -0
  13. package/src/executors/cargo-check/executor.d.ts +7 -0
  14. package/src/executors/cargo-check/executor.js +68634 -0
  15. package/src/executors/cargo-check/schema.d.ts +3 -0
  16. package/src/executors/cargo-check/schema.json +138 -0
  17. package/src/executors/cargo-clippy/executor.d.ts +7 -0
  18. package/src/executors/cargo-clippy/executor.js +68635 -0
  19. package/src/executors/cargo-clippy/schema.d.ts +3 -0
  20. package/src/executors/cargo-clippy/schema.json +36 -0
  21. package/src/executors/cargo-doc/executor.d.ts +7 -0
  22. package/src/executors/cargo-doc/executor.js +68640 -0
  23. package/src/executors/cargo-doc/schema.d.ts +3 -0
  24. package/src/executors/cargo-doc/schema.json +146 -0
  25. package/src/executors/cargo-format/executor.d.ts +7 -0
  26. package/src/executors/cargo-format/executor.js +68635 -0
  27. package/src/executors/cargo-format/schema.d.ts +3 -0
  28. package/src/executors/cargo-format/schema.json +134 -0
  29. package/src/plugins/rust/cargo-toml.d.ts +11 -0
  30. package/src/plugins/rust/index.js +99 -34
  31. package/src/plugins/typescript/index.js +1 -1
  32. package/src/utils/cargo.d.ts +4 -0
  33. package/src/utils/index.js +50 -0
@@ -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);
@@ -179,16 +200,34 @@ var createNodes = [
179
200
  "lint-ls": {
180
201
  cache: true,
181
202
  inputs: ["linting", "rust", "^production"],
182
- dependsOn: ["^lint-ls"]
203
+ dependsOn: ["^lint-ls"],
204
+ options: {
205
+ command: 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/.ls-lint.yml" ',
206
+ color: true
207
+ }
183
208
  },
184
209
  lint: {
185
210
  cache: true,
186
211
  inputs: ["linting", "rust", "^production"],
187
- dependsOn: ["lint-ls", "^lint"],
188
- executor: "@monodon/rust:lint",
212
+ dependsOn: ["^lint"],
213
+ executor: "@storm-software/workspace-tools:cargo-clippy",
189
214
  options: {
190
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
191
- }
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
192
231
  },
193
232
  "format-readme": {
194
233
  cache: true,
@@ -200,23 +239,42 @@ var createNodes = [
200
239
  inputs: ["linting", "rust", "^production"],
201
240
  dependsOn: ["^format-toml"]
202
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
+ },
203
254
  format: {
204
255
  cache: true,
205
256
  inputs: ["linting", "documentation", "rust", "^production"],
206
- dependsOn: ["format-readme", "format-toml", "^format"],
207
- 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",
208
264
  options: {
209
- command: `cargo fmt -p ${project.name}`,
210
- color: true
211
- }
265
+ toolchain: opts.toolchain,
266
+ fix: true
267
+ },
268
+ defaultConfiguration: "development",
269
+ configurations
212
270
  },
213
271
  clean: {
214
272
  cache: true,
215
273
  inputs: ["rust", "^production"],
216
- outputs: [`{workspaceRoot}/dist/target/${cargoPackage.name}`],
274
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
217
275
  executor: "nx:run-commands",
218
276
  options: {
219
- command: `pnpm exec rimraf dist/target/${cargoPackage.name}`,
277
+ command: `pnpm exec rimraf dist/target/crates/${cargoPackage.name}`,
220
278
  color: true,
221
279
  cwd: "{workspaceRoot}"
222
280
  }
@@ -225,21 +283,25 @@ var createNodes = [
225
283
  cache: true,
226
284
  inputs: ["rust", "^production"],
227
285
  dependsOn: ["build-base", "^build"],
228
- executor: "@monodon/rust:check",
229
- outputs: ["{options.target-dir}"],
286
+ executor: "@storm-software/workspace-tools:cargo-build",
287
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
230
288
  options: {
231
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
232
- }
289
+ toolchain: opts.toolchain
290
+ },
291
+ defaultConfiguration: "development",
292
+ configurations
233
293
  },
234
294
  rebuild: {
235
295
  cache: false,
236
296
  inputs: ["rust", "^production"],
237
297
  dependsOn: ["clean", "^build"],
238
- executor: "@monodon/rust:check",
239
- outputs: ["{options.target-dir}"],
298
+ executor: "@storm-software/workspace-tools:cargo-build",
299
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
240
300
  options: {
241
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
242
- }
301
+ toolchain: opts.toolchain
302
+ },
303
+ defaultConfiguration: "development",
304
+ configurations
243
305
  },
244
306
  test: {
245
307
  cache: true,
@@ -248,26 +310,24 @@ var createNodes = [
248
310
  executor: "@monodon/rust:test",
249
311
  outputs: ["{options.target-dir}"],
250
312
  options: {
251
- "target-dir": `{workspaceRoot}/dist/target/${cargoPackage.name}`
313
+ "target-dir": `{workspaceRoot}/dist/target/{projectRoot}`
252
314
  },
253
- configurations: {
254
- production: {
255
- release: true
256
- }
257
- }
315
+ defaultConfiguration: "development",
316
+ configurations
258
317
  }
259
318
  };
260
319
  if (opts.skipDocs != true) {
261
320
  project.targets.docs = {
262
321
  cache: true,
263
322
  inputs: ["linting", "documentation", "default", "^production"],
264
- dependsOn: ["build", "lint-docs", "^docs"],
265
- outputs: [`{workspaceRoot}/dist/docs/${cargoPackage.name}`],
266
- 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",
267
326
  options: {
268
- command: `cargo doc -p ${project.name} --target-dir dist/docs/${cargoPackage.name}`,
269
- color: true
270
- }
327
+ toolchain: opts.toolchain
328
+ },
329
+ defaultConfiguration: "development",
330
+ configurations
271
331
  };
272
332
  }
273
333
  if (cargoPackage.publish === null || cargoPackage.publish === void 0 || cargoPackage.publish === true || Array.isArray(cargoPackage.publish) && cargoPackage.publish.length > 0) {
@@ -280,10 +340,13 @@ var createNodes = [
280
340
  "rust",
281
341
  "^production"
282
342
  ],
343
+ dependsOn: ["build", "^nx-release-publish"],
283
344
  executor: "@storm-software/workspace-tools:cargo-publish",
284
345
  options: {
285
346
  packageRoot: root
286
- }
347
+ },
348
+ defaultConfiguration: "development",
349
+ configurations
287
350
  };
288
351
  }
289
352
  addProjectTag(
@@ -368,7 +431,9 @@ function createDependency(pkg, depName, type) {
368
431
  }
369
432
  // Annotate the CommonJS export names for ESM import in node:
370
433
  0 && (module.exports = {
434
+ DefaultCargoPluginProfileMap,
371
435
  createDependencies,
372
436
  createNodes,
437
+ description,
373
438
  name
374
439
  });
@@ -125,7 +125,7 @@ var createNodes = [
125
125
  dependsOn: ["^lint-ls"],
126
126
  executor: "nx:run-commands",
127
127
  options: {
128
- command: 'pnpm exec ls-lint --config="@storm-software/linting-tools/ls-lint/ls-lint.yml" ',
128
+ command: 'pnpm exec ls-lint --config="@storm-software/linting-tools/ls-lint/.ls-lint.yml" ',
129
129
  color: true
130
130
  }
131
131
  };
@@ -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,