@storm-software/workspace-tools 1.281.2 → 1.281.3

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.
@@ -1,377 +0,0 @@
1
- import {
2
- getRoot
3
- } from "./chunk-FHBOYSRN.mjs";
4
- import {
5
- ProjectTagConstants,
6
- addProjectTag,
7
- setDefaultProjectTags
8
- } from "./chunk-F66XEAID.mjs";
9
- import {
10
- cargoMetadata,
11
- isExternal
12
- } from "./chunk-6LP3KKXE.mjs";
13
-
14
- // src/plugins/rust/cargo-toml.ts
15
- import {
16
- createNodesFromFiles,
17
- joinPathFragments,
18
- readJsonFile,
19
- workspaceRoot
20
- } from "@nx/devkit";
21
- import { existsSync } from "node:fs";
22
- import { dirname } from "node:path";
23
- import {
24
- DependencyType
25
- } from "nx/src/config/project-graph";
26
- var name = "storm-software/rust";
27
- var description = "Plugin for parsing Cargo.toml files";
28
- var DefaultCargoPluginProfileMap = {
29
- development: "dev",
30
- production: "prod"
31
- };
32
- var DEFAULT_ERROR_MESSAGE = "An error occurred in the Storm Rust Nx plugin.";
33
- var createNodesV2 = [
34
- "*/**/Cargo.toml",
35
- async (configFiles, options, context) => {
36
- return await createNodesFromFiles(
37
- (configFile, options2, context2) => {
38
- try {
39
- const profiles = options2?.profiles ?? {};
40
- const includeApps = options2?.includeApps ?? true;
41
- const toolchain = options2?.toolchain;
42
- const skipDocs = options2?.skipDocs ?? false;
43
- const metadata = cargoMetadata();
44
- if (!metadata) {
45
- return {};
46
- }
47
- const { packages: cargoPackages } = metadata;
48
- const externalNodes = {};
49
- const projects = {};
50
- const profs = {
51
- ...DefaultCargoPluginProfileMap,
52
- ...profiles
53
- };
54
- const configurations = Object.keys(profs).reduce((ret, key) => {
55
- ret[key] = {
56
- profile: profs[key]
57
- };
58
- return ret;
59
- }, {});
60
- const cargoPackageMap = cargoPackages.reduce((acc, p) => {
61
- if (!acc.has(p.name)) {
62
- acc.set(p.name, p);
63
- }
64
- return acc;
65
- }, /* @__PURE__ */ new Map());
66
- for (const cargoPackage of cargoPackages) {
67
- if (!isExternal(cargoPackage, context2.workspaceRoot)) {
68
- const root = getRoot(dirname(configFile), context2);
69
- const project = {
70
- root,
71
- name: cargoPackage.name
72
- };
73
- if (existsSync(joinPathFragments(root, "project.json"))) {
74
- const projectJson = readJsonFile(
75
- joinPathFragments(root, "project.json")
76
- );
77
- if (projectJson) {
78
- Object.keys(projectJson).forEach((key) => {
79
- if (!project[key]) {
80
- project[key] = projectJson[key];
81
- }
82
- });
83
- }
84
- }
85
- if (includeApps === false && project.projectType === "application") {
86
- continue;
87
- }
88
- project.targets = {
89
- "lint-markdown": {
90
- cache: true,
91
- outputs: ["{projectRoot}/**/*.md", "{projectRoot}/**/*.mdx"],
92
- inputs: [
93
- "linting",
94
- "{projectRoot}/**/*.md",
95
- "{projectRoot}/**/*.mdx"
96
- ],
97
- dependsOn: ["^lint-markdown"],
98
- executor: "nx:run-commands",
99
- options: {
100
- command: 'pnpm exec markdownlint-cli2 "{projectRoot}/*.{md,mdx}" "{projectRoot}/**/*.{md,mdx}" --config "node_modules/@storm-software/markdownlint/config/base.markdownlint-cli2.jsonc" --fix'
101
- }
102
- },
103
- "lint-ls": {
104
- cache: true,
105
- inputs: ["linting", "rust", "^production"],
106
- dependsOn: ["^lint-ls"],
107
- options: {
108
- command: 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/.ls-lint.yml" ',
109
- color: true
110
- }
111
- },
112
- lint: {
113
- cache: true,
114
- inputs: ["linting", "rust", "^production"],
115
- dependsOn: ["lint-ls", "lint-markdown", "^lint"],
116
- executor: "@storm-software/workspace-tools:cargo-clippy",
117
- options: {
118
- toolchain,
119
- fix: false
120
- },
121
- defaultConfiguration: "development",
122
- configurations
123
- },
124
- check: {
125
- cache: true,
126
- inputs: ["linting", "rust", "^production"],
127
- dependsOn: ["lint", "^check"],
128
- executor: "@storm-software/workspace-tools:cargo-check",
129
- options: {
130
- toolchain
131
- },
132
- defaultConfiguration: "development",
133
- configurations
134
- },
135
- "format-readme": {
136
- cache: true,
137
- inputs: [
138
- "linting",
139
- "documentation",
140
- "{projectRoot}/{README.md,package.json,Cargo.toml,executors.json,generators.json}"
141
- ],
142
- outputs: ["{projectRoot}/README.md"],
143
- dependsOn: ["^format-readme"],
144
- executor: "nx:run-commands",
145
- options: {
146
- command: 'pnpm exec storm-git readme --templates="tools/readme-templates" --project="{projectName}"'
147
- }
148
- },
149
- "format-toml": {
150
- cache: true,
151
- inputs: ["linting", "{projectRoot}/**/*.toml"],
152
- outputs: ["{projectRoot}/**/*.toml"],
153
- dependsOn: ["^format-toml"],
154
- executor: "nx:run-commands",
155
- options: {
156
- command: 'pnpm exec taplo format --config="node_modules/@storm-software/linting-tools/taplo/config.toml" --cache-path="node_modules/.cache/taplo/{projectRoot}" --colors="always" "{projectRoot}/*.toml" "{projectRoot}/**/*.toml" '
157
- }
158
- },
159
- "format-clippy": {
160
- cache: true,
161
- inputs: ["linting", "rust", "^production"],
162
- dependsOn: ["^format-clippy"],
163
- executor: "@storm-software/workspace-tools:cargo-clippy",
164
- options: {
165
- toolchain,
166
- fix: true
167
- },
168
- defaultConfiguration: "development",
169
- configurations
170
- },
171
- format: {
172
- cache: true,
173
- inputs: ["linting", "documentation", "rust", "^production"],
174
- dependsOn: [
175
- "format-readme",
176
- "format-clippy",
177
- "format-toml",
178
- "^format"
179
- ],
180
- executor: "@storm-software/workspace-tools:cargo-format",
181
- options: {
182
- toolchain,
183
- fix: true
184
- },
185
- defaultConfiguration: "development",
186
- configurations
187
- },
188
- clean: {
189
- cache: true,
190
- inputs: ["rust", "^production"],
191
- outputs: [`{workspaceRoot}/dist/{projectRoot}/target`],
192
- executor: "nx:run-commands",
193
- options: {
194
- command: `pnpm exec rimraf dist/{projectRoot}/target`,
195
- color: true,
196
- cwd: "{workspaceRoot}"
197
- }
198
- },
199
- build: {
200
- cache: true,
201
- inputs: ["rust", "^production"],
202
- dependsOn: ["build-base", "^build"],
203
- executor: "@storm-software/workspace-tools:cargo-build",
204
- outputs: [`{workspaceRoot}/dist/{projectRoot}/target`],
205
- options: {
206
- toolchain
207
- },
208
- defaultConfiguration: "development",
209
- configurations
210
- },
211
- rebuild: {
212
- cache: false,
213
- inputs: ["rust", "^production"],
214
- dependsOn: ["clean", "build-base", "^build"],
215
- executor: "@storm-software/workspace-tools:cargo-build",
216
- outputs: [`{workspaceRoot}/dist/{projectRoot}/target`],
217
- options: {
218
- toolchain
219
- },
220
- defaultConfiguration: "development",
221
- configurations
222
- },
223
- test: {
224
- cache: true,
225
- inputs: ["testing", "rust", "^production"],
226
- dependsOn: ["build", "^test"],
227
- executor: "@monodon/rust:test",
228
- outputs: ["{options.target-dir}"],
229
- options: {
230
- "target-dir": `{workspaceRoot}/dist/{projectRoot}/target`
231
- },
232
- defaultConfiguration: "development",
233
- configurations
234
- }
235
- };
236
- if (skipDocs != true) {
237
- project.targets.docs = {
238
- cache: true,
239
- inputs: ["linting", "documentation", "^production"],
240
- dependsOn: ["format-readme", "lint-docs", "^docs"],
241
- outputs: [`{workspaceRoot}/dist/{projectRoot}/docs`],
242
- executor: "@storm-software/workspace-tools:cargo-doc",
243
- options: {
244
- toolchain
245
- },
246
- defaultConfiguration: "production",
247
- configurations
248
- };
249
- }
250
- if (cargoPackage.publish === null || cargoPackage.publish === void 0 || cargoPackage.publish === true || Array.isArray(cargoPackage.publish) && cargoPackage.publish.length > 0) {
251
- addProjectTag(
252
- project,
253
- ProjectTagConstants.Registry.TAG_ID,
254
- ProjectTagConstants.Registry.CARGO,
255
- { overwrite: true }
256
- );
257
- project.targets["nx-release-publish"] = {
258
- cache: true,
259
- inputs: [
260
- "linting",
261
- "testing",
262
- "documentation",
263
- "rust",
264
- "^production"
265
- ],
266
- dependsOn: ["build", "^nx-release-publish"],
267
- executor: "@storm-software/workspace-tools:cargo-publish",
268
- options: {
269
- packageRoot: root
270
- },
271
- defaultConfiguration: "production",
272
- configurations
273
- };
274
- }
275
- addProjectTag(
276
- project,
277
- ProjectTagConstants.Language.TAG_ID,
278
- ProjectTagConstants.Language.RUST,
279
- { overwrite: true }
280
- );
281
- setDefaultProjectTags(project, name);
282
- projects[root] = {
283
- ...project,
284
- release: {
285
- ...project.release,
286
- version: {
287
- ...project.release?.version,
288
- generator: "@storm-software/workspace-tools:release-version"
289
- }
290
- }
291
- };
292
- }
293
- for (const dep of cargoPackage.dependencies) {
294
- if (isExternal(dep, context2.workspaceRoot)) {
295
- const externalDepName = `cargo:${dep.name}`;
296
- if (!externalNodes?.[externalDepName]) {
297
- externalNodes[externalDepName] = {
298
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
- type: "cargo",
300
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
301
- name: externalDepName,
302
- data: {
303
- packageName: dep.name,
304
- version: cargoPackageMap.get(dep.name)?.version ?? "0.0.0"
305
- }
306
- };
307
- }
308
- }
309
- }
310
- }
311
- return {
312
- projects,
313
- externalNodes
314
- };
315
- } catch (e) {
316
- console.error(DEFAULT_ERROR_MESSAGE);
317
- console.error(e);
318
- throw new Error(DEFAULT_ERROR_MESSAGE, { cause: e });
319
- }
320
- },
321
- configFiles,
322
- options,
323
- context
324
- );
325
- }
326
- ];
327
- var createDependencies = (_, context) => {
328
- const metadata = cargoMetadata();
329
- if (!metadata) {
330
- return [];
331
- }
332
- const { packages: cargoPackages } = metadata;
333
- const dependencies = [];
334
- for (const pkg of cargoPackages) {
335
- if (context.projects[pkg.name]) {
336
- for (const deps of pkg.dependencies) {
337
- if (!cargoPackages.find((p) => p.name === deps.name)) {
338
- console.debug(
339
- `[storm-software/rust]: Dependency ${deps.name} not found in the cargo metadata.`
340
- );
341
- continue;
342
- }
343
- if (context.projects[deps.name]) {
344
- dependencies.push(
345
- createDependency(pkg, deps.name, DependencyType.static)
346
- );
347
- } else {
348
- const externalDepName = `cargo:${deps.name}`;
349
- if (externalDepName in (context.externalNodes ?? {})) {
350
- dependencies.push(
351
- createDependency(pkg, externalDepName, DependencyType.static)
352
- );
353
- }
354
- }
355
- }
356
- }
357
- }
358
- return dependencies;
359
- };
360
- function createDependency(pkg, depName, type) {
361
- const target = pkg.manifest_path.replace(/\\/g, "/");
362
- return {
363
- type,
364
- source: pkg.name,
365
- target: depName,
366
- sourceFile: target.replace(`${workspaceRoot.replace(/\\/g, "/")}/`, "")
367
- };
368
- }
369
-
370
- export {
371
- name,
372
- description,
373
- DefaultCargoPluginProfileMap,
374
- DEFAULT_ERROR_MESSAGE,
375
- createNodesV2,
376
- createDependencies
377
- };
@@ -1,41 +0,0 @@
1
- import {
2
- withRunExecutor
3
- } from "./chunk-HJHJTEFF.mjs";
4
- import {
5
- buildCargoCommand,
6
- cargoCommand
7
- } from "./chunk-6LP3KKXE.mjs";
8
-
9
- // src/executors/cargo-doc/executor.ts
10
- async function cargoDocExecutor(options, context) {
11
- const opts = { ...options };
12
- opts["no-deps"] = opts.noDeps;
13
- delete opts.noDeps;
14
- const command = buildCargoCommand("doc", options, context);
15
- return await cargoCommand(...command);
16
- }
17
- var executor_default = withRunExecutor(
18
- "Cargo - Doc",
19
- cargoDocExecutor,
20
- {
21
- skipReadingConfig: false,
22
- hooks: {
23
- applyDefaultOptions: (options) => {
24
- options.outputPath ??= "dist/{projectRoot}/docs";
25
- options.toolchain ??= "stable";
26
- options.release ??= options.profile ? false : true;
27
- options.allFeatures ??= true;
28
- options.lib ??= true;
29
- options.bins ??= true;
30
- options.examples ??= true;
31
- options.noDeps ??= false;
32
- return options;
33
- }
34
- }
35
- }
36
- );
37
-
38
- export {
39
- cargoDocExecutor,
40
- executor_default
41
- };