@storm-software/workspace-tools 1.178.1 → 1.179.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.
@@ -19,6 +19,7 @@ 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
+ DEFAULT_ERROR_MESSAGE: () => DEFAULT_ERROR_MESSAGE,
22
23
  DefaultCargoPluginProfileMap: () => DefaultCargoPluginProfileMap,
23
24
  createDependencies: () => createDependencies,
24
25
  createNodes: () => createNodes,
@@ -152,6 +153,7 @@ var DefaultCargoPluginProfileMap = {
152
153
  development: "dev",
153
154
  production: "prod"
154
155
  };
156
+ var DEFAULT_ERROR_MESSAGE = "An error occurred in the Storm Rust Nx plugin.";
155
157
  var createNodes = [
156
158
  "*/**/Cargo.toml",
157
159
  (cargoFile, opts = {
@@ -159,248 +161,254 @@ var createNodes = [
159
161
  skipDocs: false,
160
162
  profiles: {}
161
163
  }, ctx) => {
162
- const metadata = cargoMetadata();
163
- if (!metadata) {
164
- return {};
165
- }
166
- const { packages: cargoPackages } = metadata;
167
- const externalNodes = {};
168
- const projects = {};
169
- const profiles = {
170
- ...DefaultCargoPluginProfileMap,
171
- ...opts.profiles
172
- };
173
- const configurations = Object.keys(profiles).reduce((ret, key) => {
174
- ret[key] = {
175
- profile: profiles[key]
176
- };
177
- return ret;
178
- }, {});
179
- const cargoPackageMap = cargoPackages.reduce((acc, p) => {
180
- if (!acc.has(p.name)) {
181
- acc.set(p.name, p);
164
+ try {
165
+ const metadata = cargoMetadata();
166
+ if (!metadata) {
167
+ return {};
182
168
  }
183
- return acc;
184
- }, /* @__PURE__ */ new Map());
185
- for (const cargoPackage of cargoPackages) {
186
- if (!isExternal(cargoPackage, ctx.workspaceRoot)) {
187
- const root = (0, import_node_path2.dirname)(cargoFile);
188
- const project = {
189
- root,
190
- name: cargoPackage.name
169
+ const { packages: cargoPackages } = metadata;
170
+ const externalNodes = {};
171
+ const projects = {};
172
+ const profiles = {
173
+ ...DefaultCargoPluginProfileMap,
174
+ ...opts.profiles
175
+ };
176
+ const configurations = Object.keys(profiles).reduce((ret, key) => {
177
+ ret[key] = {
178
+ profile: profiles[key]
191
179
  };
192
- if ((0, import_node_fs.existsSync)((0, import_devkit2.joinPathFragments)(root, "project.json"))) {
193
- const projectJson = (0, import_devkit2.readJsonFile)(
194
- (0, import_devkit2.joinPathFragments)(root, "project.json")
195
- );
196
- if (projectJson) {
197
- Object.keys(projectJson).forEach((key) => {
198
- if (!project[key]) {
199
- project[key] = projectJson[key];
200
- }
201
- });
202
- }
180
+ return ret;
181
+ }, {});
182
+ const cargoPackageMap = cargoPackages.reduce((acc, p) => {
183
+ if (!acc.has(p.name)) {
184
+ acc.set(p.name, p);
203
185
  }
204
- if (opts.includeApps === false && project.projectType === "application") {
205
- continue;
206
- }
207
- project.targets = {
208
- "lint-ls": {
209
- cache: true,
210
- inputs: ["linting", "rust", "^production"],
211
- dependsOn: ["^lint-ls"],
212
- options: {
213
- command: 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/.ls-lint.yml" ',
214
- color: true
186
+ return acc;
187
+ }, /* @__PURE__ */ new Map());
188
+ for (const cargoPackage of cargoPackages) {
189
+ if (!isExternal(cargoPackage, ctx.workspaceRoot)) {
190
+ const root = (0, import_node_path2.dirname)(cargoFile);
191
+ const project = {
192
+ root,
193
+ name: cargoPackage.name
194
+ };
195
+ if ((0, import_node_fs.existsSync)((0, import_devkit2.joinPathFragments)(root, "project.json"))) {
196
+ const projectJson = (0, import_devkit2.readJsonFile)(
197
+ (0, import_devkit2.joinPathFragments)(root, "project.json")
198
+ );
199
+ if (projectJson) {
200
+ Object.keys(projectJson).forEach((key) => {
201
+ if (!project[key]) {
202
+ project[key] = projectJson[key];
203
+ }
204
+ });
215
205
  }
216
- },
217
- lint: {
218
- cache: true,
219
- inputs: ["linting", "rust", "^production"],
220
- dependsOn: ["^lint"],
221
- executor: "@storm-software/workspace-tools:cargo-clippy",
222
- options: {
223
- toolchain: opts.toolchain,
224
- fix: false
206
+ }
207
+ if (opts.includeApps === false && project.projectType === "application") {
208
+ continue;
209
+ }
210
+ project.targets = {
211
+ "lint-ls": {
212
+ cache: true,
213
+ inputs: ["linting", "rust", "^production"],
214
+ dependsOn: ["^lint-ls"],
215
+ options: {
216
+ command: 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/.ls-lint.yml" ',
217
+ color: true
218
+ }
225
219
  },
226
- defaultConfiguration: "development",
227
- configurations
228
- },
229
- check: {
230
- cache: true,
231
- inputs: ["linting", "rust", "^production"],
232
- dependsOn: ["lint", "^check"],
233
- executor: "@storm-software/workspace-tools:cargo-check",
234
- options: {
235
- toolchain: opts.toolchain
220
+ lint: {
221
+ cache: true,
222
+ inputs: ["linting", "rust", "^production"],
223
+ dependsOn: ["^lint"],
224
+ executor: "@storm-software/workspace-tools:cargo-clippy",
225
+ options: {
226
+ toolchain: opts.toolchain,
227
+ fix: false
228
+ },
229
+ defaultConfiguration: "development",
230
+ configurations
236
231
  },
237
- defaultConfiguration: "development",
238
- configurations
239
- },
240
- "format-readme": {
241
- cache: true,
242
- inputs: ["linting", "documentation", "rust", "^production"],
243
- dependsOn: ["^format-readme"]
244
- },
245
- "format-toml": {
246
- cache: true,
247
- inputs: ["linting", "rust", "^production"],
248
- dependsOn: ["^format-toml"]
249
- },
250
- "format-clippy": {
251
- cache: true,
252
- inputs: ["linting", "rust", "^production"],
253
- dependsOn: ["^format-clippy"],
254
- executor: "@storm-software/workspace-tools:cargo-clippy",
255
- options: {
256
- toolchain: opts.toolchain,
257
- fix: true
232
+ check: {
233
+ cache: true,
234
+ inputs: ["linting", "rust", "^production"],
235
+ dependsOn: ["lint", "^check"],
236
+ executor: "@storm-software/workspace-tools:cargo-check",
237
+ options: {
238
+ toolchain: opts.toolchain
239
+ },
240
+ defaultConfiguration: "development",
241
+ configurations
258
242
  },
259
- defaultConfiguration: "development",
260
- configurations
261
- },
262
- format: {
263
- cache: true,
264
- inputs: ["linting", "documentation", "rust", "^production"],
265
- dependsOn: [
266
- "format-readme",
267
- "format-clippy",
268
- "format-toml",
269
- "^format"
270
- ],
271
- executor: "@storm-software/workspace-tools:cargo-format",
272
- options: {
273
- toolchain: opts.toolchain,
274
- fix: true
243
+ "format-readme": {
244
+ cache: true,
245
+ inputs: ["linting", "documentation", "rust", "^production"],
246
+ dependsOn: ["^format-readme"]
275
247
  },
276
- defaultConfiguration: "development",
277
- configurations
278
- },
279
- clean: {
280
- cache: true,
281
- inputs: ["rust", "^production"],
282
- outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
283
- executor: "nx:run-commands",
284
- options: {
285
- command: `pnpm exec rimraf dist/target/crates/${cargoPackage.name}`,
286
- color: true,
287
- cwd: "{workspaceRoot}"
288
- }
289
- },
290
- build: {
291
- cache: true,
292
- inputs: ["rust", "^production"],
293
- dependsOn: ["build-base", "^build"],
294
- executor: "@storm-software/workspace-tools:cargo-build",
295
- outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
296
- options: {
297
- toolchain: opts.toolchain
248
+ "format-toml": {
249
+ cache: true,
250
+ inputs: ["linting", "rust", "^production"],
251
+ dependsOn: ["^format-toml"]
298
252
  },
299
- defaultConfiguration: "development",
300
- configurations
301
- },
302
- rebuild: {
303
- cache: false,
304
- inputs: ["rust", "^production"],
305
- dependsOn: ["clean", "^build"],
306
- executor: "@storm-software/workspace-tools:cargo-build",
307
- outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
308
- options: {
309
- toolchain: opts.toolchain
253
+ "format-clippy": {
254
+ cache: true,
255
+ inputs: ["linting", "rust", "^production"],
256
+ dependsOn: ["^format-clippy"],
257
+ executor: "@storm-software/workspace-tools:cargo-clippy",
258
+ options: {
259
+ toolchain: opts.toolchain,
260
+ fix: true
261
+ },
262
+ defaultConfiguration: "development",
263
+ configurations
310
264
  },
311
- defaultConfiguration: "development",
312
- configurations
313
- },
314
- test: {
315
- cache: true,
316
- inputs: ["testing", "rust", "^production"],
317
- dependsOn: ["build", "^test"],
318
- executor: "@monodon/rust:test",
319
- outputs: ["{options.target-dir}"],
320
- options: {
321
- "target-dir": `{workspaceRoot}/dist/target/{projectRoot}`
265
+ format: {
266
+ cache: true,
267
+ inputs: ["linting", "documentation", "rust", "^production"],
268
+ dependsOn: [
269
+ "format-readme",
270
+ "format-clippy",
271
+ "format-toml",
272
+ "^format"
273
+ ],
274
+ executor: "@storm-software/workspace-tools:cargo-format",
275
+ options: {
276
+ toolchain: opts.toolchain,
277
+ fix: true
278
+ },
279
+ defaultConfiguration: "development",
280
+ configurations
322
281
  },
323
- defaultConfiguration: "development",
324
- configurations
325
- }
326
- };
327
- if (opts.skipDocs != true) {
328
- project.targets.docs = {
329
- cache: true,
330
- inputs: ["linting", "documentation", "default", "^production"],
331
- dependsOn: ["format-readme", "lint-docs", "^docs"],
332
- outputs: [`{workspaceRoot}/dist/docs/{projectRoot}`],
333
- executor: "@storm-software/workspace-tools:cargo-doc",
334
- options: {
335
- toolchain: opts.toolchain
282
+ clean: {
283
+ cache: true,
284
+ inputs: ["rust", "^production"],
285
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
286
+ executor: "nx:run-commands",
287
+ options: {
288
+ command: `pnpm exec rimraf dist/target/crates/${cargoPackage.name}`,
289
+ color: true,
290
+ cwd: "{workspaceRoot}"
291
+ }
292
+ },
293
+ build: {
294
+ cache: true,
295
+ inputs: ["rust", "^production"],
296
+ dependsOn: ["build-base", "^build"],
297
+ executor: "@storm-software/workspace-tools:cargo-build",
298
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
299
+ options: {
300
+ toolchain: opts.toolchain
301
+ },
302
+ defaultConfiguration: "development",
303
+ configurations
336
304
  },
337
- defaultConfiguration: "production",
338
- configurations
305
+ rebuild: {
306
+ cache: false,
307
+ inputs: ["rust", "^production"],
308
+ dependsOn: ["clean", "^build"],
309
+ executor: "@storm-software/workspace-tools:cargo-build",
310
+ outputs: [`{workspaceRoot}/dist/target/{projectRoot}`],
311
+ options: {
312
+ toolchain: opts.toolchain
313
+ },
314
+ defaultConfiguration: "development",
315
+ configurations
316
+ },
317
+ test: {
318
+ cache: true,
319
+ inputs: ["testing", "rust", "^production"],
320
+ dependsOn: ["build", "^test"],
321
+ executor: "@monodon/rust:test",
322
+ outputs: ["{options.target-dir}"],
323
+ options: {
324
+ "target-dir": `{workspaceRoot}/dist/target/{projectRoot}`
325
+ },
326
+ defaultConfiguration: "development",
327
+ configurations
328
+ }
339
329
  };
340
- }
341
- if (cargoPackage.publish === null || cargoPackage.publish === void 0 || cargoPackage.publish === true || Array.isArray(cargoPackage.publish) && cargoPackage.publish.length > 0) {
330
+ if (opts.skipDocs != true) {
331
+ project.targets.docs = {
332
+ cache: true,
333
+ inputs: ["linting", "documentation", "default", "^production"],
334
+ dependsOn: ["format-readme", "lint-docs", "^docs"],
335
+ outputs: [`{workspaceRoot}/dist/docs/{projectRoot}`],
336
+ executor: "@storm-software/workspace-tools:cargo-doc",
337
+ options: {
338
+ toolchain: opts.toolchain
339
+ },
340
+ defaultConfiguration: "production",
341
+ configurations
342
+ };
343
+ }
344
+ if (cargoPackage.publish === null || cargoPackage.publish === void 0 || cargoPackage.publish === true || Array.isArray(cargoPackage.publish) && cargoPackage.publish.length > 0) {
345
+ addProjectTag(
346
+ project,
347
+ ProjectTagConstants.Registry.TAG_ID,
348
+ ProjectTagConstants.Registry.CARGO,
349
+ { overwrite: true }
350
+ );
351
+ project.targets["nx-release-publish"] = {
352
+ cache: true,
353
+ inputs: [
354
+ "linting",
355
+ "testing",
356
+ "documentation",
357
+ "rust",
358
+ "^production"
359
+ ],
360
+ dependsOn: ["build", "^nx-release-publish"],
361
+ executor: "@storm-software/workspace-tools:cargo-publish",
362
+ options: {
363
+ packageRoot: root
364
+ },
365
+ defaultConfiguration: "production",
366
+ configurations
367
+ };
368
+ }
342
369
  addProjectTag(
343
370
  project,
344
- ProjectTagConstants.Registry.TAG_ID,
345
- ProjectTagConstants.Registry.CARGO,
371
+ ProjectTagConstants.Language.TAG_ID,
372
+ ProjectTagConstants.Language.RUST,
346
373
  { overwrite: true }
347
374
  );
348
- project.targets["nx-release-publish"] = {
349
- cache: true,
350
- inputs: [
351
- "linting",
352
- "testing",
353
- "documentation",
354
- "rust",
355
- "^production"
356
- ],
357
- dependsOn: ["build", "^nx-release-publish"],
358
- executor: "@storm-software/workspace-tools:cargo-publish",
359
- options: {
360
- packageRoot: root
361
- },
362
- defaultConfiguration: "production",
363
- configurations
375
+ setDefaultProjectTags(project);
376
+ projects[root] = {
377
+ ...project,
378
+ release: {
379
+ ...project.release,
380
+ version: {
381
+ ...project.release?.version,
382
+ generator: "@storm-software/workspace-tools:release-version"
383
+ }
384
+ }
364
385
  };
365
386
  }
366
- addProjectTag(
367
- project,
368
- ProjectTagConstants.Language.TAG_ID,
369
- ProjectTagConstants.Language.RUST,
370
- { overwrite: true }
371
- );
372
- setDefaultProjectTags(project);
373
- projects[root] = {
374
- ...project,
375
- release: {
376
- ...project.release,
377
- version: {
378
- ...project.release?.version,
379
- generator: "@storm-software/workspace-tools:release-version"
387
+ for (const dep of cargoPackage.dependencies) {
388
+ if (isExternal(dep, ctx.workspaceRoot)) {
389
+ const externalDepName = `cargo:${dep.name}`;
390
+ if (!externalNodes?.[externalDepName]) {
391
+ externalNodes[externalDepName] = {
392
+ type: "cargo",
393
+ name: externalDepName,
394
+ data: {
395
+ packageName: dep.name,
396
+ version: cargoPackageMap.get(dep.name)?.version ?? "0.0.0"
397
+ }
398
+ };
380
399
  }
381
400
  }
382
- };
383
- }
384
- for (const dep of cargoPackage.dependencies) {
385
- if (isExternal(dep, ctx.workspaceRoot)) {
386
- const externalDepName = `cargo:${dep.name}`;
387
- if (!externalNodes?.[externalDepName]) {
388
- externalNodes[externalDepName] = {
389
- type: "cargo",
390
- name: externalDepName,
391
- data: {
392
- packageName: dep.name,
393
- version: cargoPackageMap.get(dep.name)?.version ?? "0.0.0"
394
- }
395
- };
396
- }
397
401
  }
398
402
  }
403
+ return {
404
+ projects,
405
+ externalNodes
406
+ };
407
+ } catch (e) {
408
+ console.error(DEFAULT_ERROR_MESSAGE);
409
+ console.error(e);
410
+ throw new Error(DEFAULT_ERROR_MESSAGE, { cause: e });
399
411
  }
400
- return {
401
- projects,
402
- externalNodes
403
- };
404
412
  }
405
413
  ];
406
414
  var createDependencies = (_, context) => {
@@ -448,6 +456,7 @@ function createDependency(pkg, depName, type) {
448
456
  }
449
457
  // Annotate the CommonJS export names for ESM import in node:
450
458
  0 && (module.exports = {
459
+ DEFAULT_ERROR_MESSAGE,
451
460
  DefaultCargoPluginProfileMap,
452
461
  createDependencies,
453
462
  createNodes,