@storm-software/workspace-tools 1.296.114 → 1.297.0

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 (53) hide show
  1. package/dist/{chunk-RU4TNHFG.js → chunk-3AHXYCKA.js} +1 -2
  2. package/dist/chunk-52ZDVDIY.mjs +84 -0
  3. package/dist/chunk-G4DPDEL3.mjs +175 -0
  4. package/dist/{chunk-IK7V7SOR.js → chunk-HKZ7DBR7.js} +13 -4
  5. package/dist/chunk-KCQIASWP.js +84 -0
  6. package/dist/{chunk-TNQCJJDO.mjs → chunk-N55FJ7J3.mjs} +12 -3
  7. package/dist/{chunk-K6UOPTIZ.mjs → chunk-QQ64FCAP.mjs} +1 -2
  8. package/dist/chunk-VXOPWQTJ.js +175 -0
  9. package/dist/executors.d.mts +2 -1
  10. package/dist/executors.d.ts +2 -1
  11. package/dist/executors.js +10 -12
  12. package/dist/executors.mjs +10 -12
  13. package/dist/generators.js +3 -3
  14. package/dist/generators.mjs +3 -3
  15. package/dist/index.d.mts +4 -3
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js +14 -14
  18. package/dist/index.mjs +16 -16
  19. package/dist/{executor-BF7_LjrR.d.mts → schema.d-Muf2toJ0.d.mts} +1 -8
  20. package/dist/{executor-BF7_LjrR.d.ts → schema.d-Muf2toJ0.d.ts} +1 -8
  21. package/dist/schema.d-vPuQzus3.d.mts +41 -0
  22. package/dist/schema.d-vPuQzus3.d.ts +41 -0
  23. package/dist/src/executors/cargo-publish/executor.js +2 -2
  24. package/dist/src/executors/cargo-publish/executor.mjs +1 -1
  25. package/dist/src/executors/command-publish/executor.d.mts +8 -0
  26. package/dist/src/executors/command-publish/executor.d.ts +8 -0
  27. package/dist/src/executors/command-publish/executor.js +7 -0
  28. package/dist/src/executors/command-publish/executor.mjs +8 -0
  29. package/dist/src/executors/command-publish/schema.d.ts +41 -0
  30. package/dist/src/executors/command-publish/schema.json +52 -0
  31. package/dist/src/executors/command-publish/untyped.d.mts +5 -0
  32. package/dist/src/executors/command-publish/untyped.d.ts +5 -0
  33. package/dist/src/executors/command-publish/untyped.js +46 -0
  34. package/dist/src/executors/command-publish/untyped.mjs +48 -0
  35. package/dist/src/executors/npm-publish/executor.d.mts +8 -2
  36. package/dist/src/executors/npm-publish/executor.d.ts +8 -2
  37. package/dist/src/executors/npm-publish/executor.js +3 -5
  38. package/dist/src/executors/npm-publish/executor.mjs +2 -4
  39. package/dist/src/utils/index.d.mts +1 -1
  40. package/dist/src/utils/index.d.ts +1 -1
  41. package/dist/src/utils/index.js +4 -2
  42. package/dist/src/utils/index.mjs +4 -2
  43. package/dist/src/utils/package-helpers.d.mts +9 -1
  44. package/dist/src/utils/package-helpers.d.ts +9 -1
  45. package/dist/src/utils/package-helpers.js +4 -2
  46. package/dist/src/utils/package-helpers.mjs +5 -3
  47. package/docs/api/executors/command-publish/schema.md +43 -0
  48. package/executors.json +5 -0
  49. package/package.json +12 -12
  50. package/dist/chunk-KD4DD3ZC.mjs +0 -94
  51. package/dist/chunk-R6QU3B53.js +0 -94
  52. /package/dist/{chunk-GHQJKIMQ.mjs → chunk-OYOYESMB.mjs} +0 -0
  53. /package/dist/{chunk-P6HSE7LH.js → chunk-TEX5JJNH.js} +0 -0
@@ -7,7 +7,6 @@ var _devkit = require('@nx/devkit');
7
7
  var _child_process = require('child_process');
8
8
  var _fs = require('fs');
9
9
  var _https = require('https'); var _https2 = _interopRequireDefault(_https);
10
- var LARGE_BUFFER = 1024 * 1e6;
11
10
  async function runExecutor(options, context) {
12
11
  const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
13
12
  if (!context.projectName) {
@@ -56,7 +55,7 @@ async function runExecutor(options, context) {
56
55
  console.log(`Running "${cargoPublishCommand}"...`);
57
56
  console.log("");
58
57
  _child_process.execSync.call(void 0, cargoPublishCommand, {
59
- maxBuffer: LARGE_BUFFER,
58
+ maxBuffer: 1024 * 1e6,
60
59
  env: {
61
60
  ...process.env,
62
61
  FORCE_COLOR: "true"
@@ -0,0 +1,84 @@
1
+ import {
2
+ joinPaths
3
+ } from "./chunk-TBW5MCN6.mjs";
4
+
5
+ // src/executors/command-publish/executor.ts
6
+ import { execSync } from "node:child_process";
7
+ import { isAbsolute } from "node:path";
8
+ async function commandPublishExecutorFn(options, context) {
9
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
10
+ if (!context.projectName) {
11
+ throw new Error("The `command-publish` executor requires a `projectName`.");
12
+ }
13
+ const projectConfig = context.projectsConfigurations?.projects?.[context.projectName];
14
+ if (!projectConfig?.root) {
15
+ throw new Error(
16
+ `Could not find project configuration for \`${context.projectName}\``
17
+ );
18
+ }
19
+ const commands = resolveCommands(options);
20
+ if (commands.length === 0) {
21
+ throw new Error(
22
+ "The `command-publish` executor requires a `command` or `commands` option."
23
+ );
24
+ }
25
+ console.info(
26
+ `\u{1F680} Running Storm Command Publish executor on the ${context.projectName} project`
27
+ );
28
+ const cwd = resolveCwd(options.cwd, context.root, projectConfig.root);
29
+ for (const command of commands) {
30
+ if (isDryRun) {
31
+ console.info(
32
+ `Would run publish command "${command}" in current working directory: "${cwd}", but [dry-run] was set.`
33
+ );
34
+ continue;
35
+ }
36
+ try {
37
+ console.info(
38
+ `Running publish command "${command}" in current working directory: "${cwd}"`
39
+ );
40
+ const result = execSync(command, {
41
+ cwd,
42
+ env: {
43
+ ...process.env,
44
+ FORCE_COLOR: "true"
45
+ },
46
+ maxBuffer: 1024 * 1e6,
47
+ killSignal: "SIGTERM"
48
+ });
49
+ console.info(
50
+ `Published ${context.projectName} successfully.${result ? `
51
+
52
+ Execution response: ${result.toString()}` : ""}`
53
+ );
54
+ } catch (error) {
55
+ console.error(`Failed to publish ${context.projectName}`);
56
+ console.error(error);
57
+ console.log("");
58
+ return { success: false };
59
+ }
60
+ }
61
+ return { success: true };
62
+ }
63
+ function resolveCommands(options) {
64
+ if (options.commands?.length) {
65
+ return options.commands.map((command) => command.trim()).filter(Boolean);
66
+ }
67
+ if (options.command?.trim()) {
68
+ return [options.command.trim()];
69
+ }
70
+ return [];
71
+ }
72
+ function resolveCwd(cwdOption, workspaceRoot, projectRoot) {
73
+ if (!cwdOption) {
74
+ return joinPaths(workspaceRoot, projectRoot);
75
+ }
76
+ if (isAbsolute(cwdOption)) {
77
+ return cwdOption;
78
+ }
79
+ return joinPaths(workspaceRoot, cwdOption);
80
+ }
81
+
82
+ export {
83
+ commandPublishExecutorFn
84
+ };
@@ -0,0 +1,175 @@
1
+ import {
2
+ parseCargoToml
3
+ } from "./chunk-UA33NH5O.mjs";
4
+ import {
5
+ ProjectTagConstants,
6
+ isEqualProjectTag
7
+ } from "./chunk-2GQSCZ3J.mjs";
8
+ import {
9
+ joinPaths
10
+ } from "./chunk-TBW5MCN6.mjs";
11
+
12
+ // src/utils/package-helpers.ts
13
+ import {
14
+ createProjectGraphAsync,
15
+ joinPathFragments,
16
+ readCachedProjectGraph,
17
+ readJsonFile
18
+ } from "@nx/devkit";
19
+ import { execFileSync } from "child_process";
20
+ import { existsSync } from "node:fs";
21
+ import { readFile, writeFile } from "node:fs/promises";
22
+ import { dirname, resolve } from "path";
23
+ import { format } from "prettier";
24
+ import prettierPlugin from "prettier-plugin-packagejson";
25
+ var PACKAGE_JSON_DEP_FIELDS = [
26
+ "dependencies",
27
+ "devDependencies",
28
+ "optionalDependencies",
29
+ "peerDependencies"
30
+ ];
31
+ var PACKAGE_JSON_FORMAT_OPTIONS = {
32
+ parser: "json",
33
+ proseWrap: "preserve",
34
+ trailingComma: "none",
35
+ tabWidth: 2,
36
+ semi: true,
37
+ singleQuote: false,
38
+ quoteProps: "as-needed",
39
+ insertPragma: false,
40
+ bracketSameLine: true,
41
+ printWidth: 80,
42
+ bracketSpacing: true,
43
+ arrowParens: "avoid",
44
+ endOfLine: "lf",
45
+ plugins: [prettierPlugin]
46
+ };
47
+ var PackageManagerTypes = {
48
+ PackageJson: "package.json",
49
+ CargoToml: "Cargo.toml"
50
+ };
51
+ var getPackageInfo = (project) => {
52
+ if (isEqualProjectTag(
53
+ project,
54
+ ProjectTagConstants.Language.TAG_ID,
55
+ ProjectTagConstants.Language.RUST
56
+ ) && existsSync(joinPathFragments(project.root, "Cargo.toml"))) {
57
+ return {
58
+ type: "Cargo.toml",
59
+ content: parseCargoToml(joinPathFragments(project.root, "Cargo.toml"))
60
+ };
61
+ } else if (isEqualProjectTag(
62
+ project,
63
+ ProjectTagConstants.Language.TAG_ID,
64
+ ProjectTagConstants.Language.TYPESCRIPT
65
+ ) && existsSync(joinPathFragments(project.root, "package.json"))) {
66
+ return {
67
+ type: "package.json",
68
+ content: readJsonFile(
69
+ joinPathFragments(project.root, "package.json")
70
+ )
71
+ };
72
+ }
73
+ return null;
74
+ };
75
+ async function getPrivateWorkspacePackageNames(workspaceRoot) {
76
+ let projectGraph;
77
+ try {
78
+ projectGraph = readCachedProjectGraph();
79
+ } catch {
80
+ await createProjectGraphAsync();
81
+ projectGraph = readCachedProjectGraph();
82
+ }
83
+ const privatePackages = /* @__PURE__ */ new Set();
84
+ await Promise.all(
85
+ Object.keys(projectGraph.nodes).map(async (node) => {
86
+ const projectNode = projectGraph.nodes[node];
87
+ if (!projectNode?.data.root) {
88
+ return;
89
+ }
90
+ const projectPackageJsonPath = joinPaths(
91
+ workspaceRoot,
92
+ projectNode.data.root,
93
+ "package.json"
94
+ );
95
+ if (!existsSync(projectPackageJsonPath)) {
96
+ return;
97
+ }
98
+ const projectPackageJson = JSON.parse(
99
+ await readFile(projectPackageJsonPath, "utf8")
100
+ );
101
+ if (projectPackageJson.private === true && projectPackageJson.name) {
102
+ privatePackages.add(projectPackageJson.name);
103
+ }
104
+ })
105
+ );
106
+ return privatePackages;
107
+ }
108
+ function stripPrivateWorkspaceDepsFromPackageJson(packageJson, privatePackages) {
109
+ const removed = [];
110
+ for (const field of PACKAGE_JSON_DEP_FIELDS) {
111
+ const deps = packageJson[field];
112
+ if (!deps || typeof deps !== "object") {
113
+ continue;
114
+ }
115
+ for (const [name, version] of Object.entries(deps)) {
116
+ if (typeof version === "string" && version.startsWith("workspace:") && privatePackages.has(name)) {
117
+ delete deps[name];
118
+ removed.push(`${field}.${name}`);
119
+ }
120
+ }
121
+ if (Object.keys(deps).length === 0) {
122
+ delete packageJson[field];
123
+ }
124
+ }
125
+ return removed;
126
+ }
127
+ async function stripPrivateWorkspaceDeps(packageRoot, workspaceRoot) {
128
+ const packageJsonPath = joinPaths(packageRoot, "package.json");
129
+ const packageJson = JSON.parse(
130
+ await readFile(packageJsonPath, "utf8")
131
+ );
132
+ const privatePackages = await getPrivateWorkspacePackageNames(workspaceRoot);
133
+ const removed = stripPrivateWorkspaceDepsFromPackageJson(
134
+ packageJson,
135
+ privatePackages
136
+ );
137
+ if (removed.length === 0) {
138
+ return removed;
139
+ }
140
+ await writeFile(
141
+ packageJsonPath,
142
+ await format(JSON.stringify(packageJson), PACKAGE_JSON_FORMAT_OPTIONS)
143
+ );
144
+ return removed;
145
+ }
146
+ async function addPackageJsonGitHead(packageRoot) {
147
+ const packageJsonPath = joinPaths(packageRoot, "package.json");
148
+ if (!packageJsonPath) {
149
+ throw new Error(
150
+ "No file path provided. Please provide a valid path to the package.json file."
151
+ );
152
+ }
153
+ const packageJsonValue = JSON.parse(await readFile(packageJsonPath, "utf8"));
154
+ if (!packageJsonValue || typeof packageJsonValue !== "object") {
155
+ throw new Error(
156
+ `Invalid package.json file at ${packageJsonPath}. Please ensure it is a valid JSON file.`
157
+ );
158
+ }
159
+ const gitHead = execFileSync("git", ["rev-parse", "HEAD"], {
160
+ cwd: dirname(resolve(packageJsonPath)),
161
+ encoding: "utf8"
162
+ }).trim();
163
+ packageJsonValue.gitHead = gitHead;
164
+ return writeFile(
165
+ packageJsonPath,
166
+ await format(JSON.stringify(packageJsonValue), PACKAGE_JSON_FORMAT_OPTIONS)
167
+ );
168
+ }
169
+
170
+ export {
171
+ PackageManagerTypes,
172
+ getPackageInfo,
173
+ stripPrivateWorkspaceDeps,
174
+ addPackageJsonGitHead
175
+ };
@@ -6,7 +6,8 @@ var _chunk3MXZ2RJFjs = require('./chunk-3MXZ2RJF.js');
6
6
  var _chunkP5OQBBN3js = require('./chunk-P5OQBBN3.js');
7
7
 
8
8
 
9
- var _chunkR6QU3B53js = require('./chunk-R6QU3B53.js');
9
+
10
+ var _chunkVXOPWQTJjs = require('./chunk-VXOPWQTJ.js');
10
11
 
11
12
 
12
13
  var _chunkIMY2BU43js = require('./chunk-IMY2BU43.js');
@@ -118,8 +119,17 @@ async function npmPublishExecutorFn(options, context) {
118
119
  );
119
120
  return { success: true };
120
121
  }
122
+ const removedPrivateWorkspaceDeps = await _chunkVXOPWQTJjs.stripPrivateWorkspaceDeps.call(void 0,
123
+ packageRoot,
124
+ context.root
125
+ );
126
+ if (removedPrivateWorkspaceDeps.length > 0) {
127
+ console.info(
128
+ `Removed private workspace dependencies from ${packageJsonPath}: ${removedPrivateWorkspaceDeps.join(", ")}`
129
+ );
130
+ }
121
131
  await replaceDepsAliases(jiti, packageRoot, context.root, packageManager);
122
- await _chunkR6QU3B53js.addPackageJsonGitHead.call(void 0, packageRoot);
132
+ await _chunkVXOPWQTJjs.addPackageJsonGitHead.call(void 0, packageRoot);
123
133
  const npmPublishCommandSegments = [`npm publish --json`];
124
134
  const npmViewCommandSegments = [
125
135
  `npm view ${packageName} versions dist-tags --json`
@@ -315,5 +325,4 @@ Error: ${JSON.stringify(
315
325
 
316
326
 
317
327
 
318
-
319
- exports.LARGE_BUFFER = LARGE_BUFFER; exports.npmPublishExecutorFn = npmPublishExecutorFn;
328
+ exports.npmPublishExecutorFn = npmPublishExecutorFn;
@@ -0,0 +1,84 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkCQDBLKPFjs = require('./chunk-CQDBLKPF.js');
4
+
5
+ // src/executors/command-publish/executor.ts
6
+ var _child_process = require('child_process');
7
+ var _path = require('path');
8
+ async function commandPublishExecutorFn(options, context) {
9
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
10
+ if (!context.projectName) {
11
+ throw new Error("The `command-publish` executor requires a `projectName`.");
12
+ }
13
+ const projectConfig = _optionalChain([context, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects, 'optionalAccess', _3 => _3[context.projectName]]);
14
+ if (!_optionalChain([projectConfig, 'optionalAccess', _4 => _4.root])) {
15
+ throw new Error(
16
+ `Could not find project configuration for \`${context.projectName}\``
17
+ );
18
+ }
19
+ const commands = resolveCommands(options);
20
+ if (commands.length === 0) {
21
+ throw new Error(
22
+ "The `command-publish` executor requires a `command` or `commands` option."
23
+ );
24
+ }
25
+ console.info(
26
+ `\u{1F680} Running Storm Command Publish executor on the ${context.projectName} project`
27
+ );
28
+ const cwd = resolveCwd(options.cwd, context.root, projectConfig.root);
29
+ for (const command of commands) {
30
+ if (isDryRun) {
31
+ console.info(
32
+ `Would run publish command "${command}" in current working directory: "${cwd}", but [dry-run] was set.`
33
+ );
34
+ continue;
35
+ }
36
+ try {
37
+ console.info(
38
+ `Running publish command "${command}" in current working directory: "${cwd}"`
39
+ );
40
+ const result = _child_process.execSync.call(void 0, command, {
41
+ cwd,
42
+ env: {
43
+ ...process.env,
44
+ FORCE_COLOR: "true"
45
+ },
46
+ maxBuffer: 1024 * 1e6,
47
+ killSignal: "SIGTERM"
48
+ });
49
+ console.info(
50
+ `Published ${context.projectName} successfully.${result ? `
51
+
52
+ Execution response: ${result.toString()}` : ""}`
53
+ );
54
+ } catch (error) {
55
+ console.error(`Failed to publish ${context.projectName}`);
56
+ console.error(error);
57
+ console.log("");
58
+ return { success: false };
59
+ }
60
+ }
61
+ return { success: true };
62
+ }
63
+ function resolveCommands(options) {
64
+ if (_optionalChain([options, 'access', _5 => _5.commands, 'optionalAccess', _6 => _6.length])) {
65
+ return options.commands.map((command) => command.trim()).filter(Boolean);
66
+ }
67
+ if (_optionalChain([options, 'access', _7 => _7.command, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()])) {
68
+ return [options.command.trim()];
69
+ }
70
+ return [];
71
+ }
72
+ function resolveCwd(cwdOption, workspaceRoot, projectRoot) {
73
+ if (!cwdOption) {
74
+ return _chunkCQDBLKPFjs.joinPaths.call(void 0, workspaceRoot, projectRoot);
75
+ }
76
+ if (_path.isAbsolute.call(void 0, cwdOption)) {
77
+ return cwdOption;
78
+ }
79
+ return _chunkCQDBLKPFjs.joinPaths.call(void 0, workspaceRoot, cwdOption);
80
+ }
81
+
82
+
83
+
84
+ exports.commandPublishExecutorFn = commandPublishExecutorFn;
@@ -5,8 +5,9 @@ import {
5
5
  getGitHubTools
6
6
  } from "./chunk-SHJC4UVH.mjs";
7
7
  import {
8
- addPackageJsonGitHead
9
- } from "./chunk-KD4DD3ZC.mjs";
8
+ addPackageJsonGitHead,
9
+ stripPrivateWorkspaceDeps
10
+ } from "./chunk-G4DPDEL3.mjs";
10
11
  import {
11
12
  getConfig
12
13
  } from "./chunk-I4KVL3GR.mjs";
@@ -118,6 +119,15 @@ async function npmPublishExecutorFn(options, context) {
118
119
  );
119
120
  return { success: true };
120
121
  }
122
+ const removedPrivateWorkspaceDeps = await stripPrivateWorkspaceDeps(
123
+ packageRoot,
124
+ context.root
125
+ );
126
+ if (removedPrivateWorkspaceDeps.length > 0) {
127
+ console.info(
128
+ `Removed private workspace dependencies from ${packageJsonPath}: ${removedPrivateWorkspaceDeps.join(", ")}`
129
+ );
130
+ }
121
131
  await replaceDepsAliases(jiti, packageRoot, context.root, packageManager);
122
132
  await addPackageJsonGitHead(packageRoot);
123
133
  const npmPublishCommandSegments = [`npm publish --json`];
@@ -314,6 +324,5 @@ Error: ${JSON.stringify(
314
324
  }
315
325
 
316
326
  export {
317
- LARGE_BUFFER,
318
327
  npmPublishExecutorFn
319
328
  };
@@ -7,7 +7,6 @@ import { joinPathFragments } from "@nx/devkit";
7
7
  import { execSync } from "node:child_process";
8
8
  import { readFileSync } from "node:fs";
9
9
  import https from "node:https";
10
- var LARGE_BUFFER = 1024 * 1e6;
11
10
  async function runExecutor(options, context) {
12
11
  const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
13
12
  if (!context.projectName) {
@@ -56,7 +55,7 @@ async function runExecutor(options, context) {
56
55
  console.log(`Running "${cargoPublishCommand}"...`);
57
56
  console.log("");
58
57
  execSync(cargoPublishCommand, {
59
- maxBuffer: LARGE_BUFFER,
58
+ maxBuffer: 1024 * 1e6,
60
59
  env: {
61
60
  ...process.env,
62
61
  FORCE_COLOR: "true"
@@ -0,0 +1,175 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkN2365RCIjs = require('./chunk-N2365RCI.js');
4
+
5
+
6
+
7
+ var _chunkTAP26ZJQjs = require('./chunk-TAP26ZJQ.js');
8
+
9
+
10
+ var _chunkCQDBLKPFjs = require('./chunk-CQDBLKPF.js');
11
+
12
+ // src/utils/package-helpers.ts
13
+
14
+
15
+
16
+
17
+
18
+ var _devkit = require('@nx/devkit');
19
+ var _child_process = require('child_process');
20
+ var _fs = require('fs');
21
+ var _promises = require('fs/promises');
22
+ var _path = require('path');
23
+ var _prettier = require('prettier');
24
+ var _prettierpluginpackagejson = require('prettier-plugin-packagejson'); var _prettierpluginpackagejson2 = _interopRequireDefault(_prettierpluginpackagejson);
25
+ var PACKAGE_JSON_DEP_FIELDS = [
26
+ "dependencies",
27
+ "devDependencies",
28
+ "optionalDependencies",
29
+ "peerDependencies"
30
+ ];
31
+ var PACKAGE_JSON_FORMAT_OPTIONS = {
32
+ parser: "json",
33
+ proseWrap: "preserve",
34
+ trailingComma: "none",
35
+ tabWidth: 2,
36
+ semi: true,
37
+ singleQuote: false,
38
+ quoteProps: "as-needed",
39
+ insertPragma: false,
40
+ bracketSameLine: true,
41
+ printWidth: 80,
42
+ bracketSpacing: true,
43
+ arrowParens: "avoid",
44
+ endOfLine: "lf",
45
+ plugins: [_prettierpluginpackagejson2.default]
46
+ };
47
+ var PackageManagerTypes = {
48
+ PackageJson: "package.json",
49
+ CargoToml: "Cargo.toml"
50
+ };
51
+ var getPackageInfo = (project) => {
52
+ if (_chunkTAP26ZJQjs.isEqualProjectTag.call(void 0,
53
+ project,
54
+ _chunkTAP26ZJQjs.ProjectTagConstants.Language.TAG_ID,
55
+ _chunkTAP26ZJQjs.ProjectTagConstants.Language.RUST
56
+ ) && _fs.existsSync.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "Cargo.toml"))) {
57
+ return {
58
+ type: "Cargo.toml",
59
+ content: _chunkN2365RCIjs.parseCargoToml.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "Cargo.toml"))
60
+ };
61
+ } else if (_chunkTAP26ZJQjs.isEqualProjectTag.call(void 0,
62
+ project,
63
+ _chunkTAP26ZJQjs.ProjectTagConstants.Language.TAG_ID,
64
+ _chunkTAP26ZJQjs.ProjectTagConstants.Language.TYPESCRIPT
65
+ ) && _fs.existsSync.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "package.json"))) {
66
+ return {
67
+ type: "package.json",
68
+ content: _devkit.readJsonFile.call(void 0,
69
+ _devkit.joinPathFragments.call(void 0, project.root, "package.json")
70
+ )
71
+ };
72
+ }
73
+ return null;
74
+ };
75
+ async function getPrivateWorkspacePackageNames(workspaceRoot) {
76
+ let projectGraph;
77
+ try {
78
+ projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
79
+ } catch (e) {
80
+ await _devkit.createProjectGraphAsync.call(void 0, );
81
+ projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
82
+ }
83
+ const privatePackages = /* @__PURE__ */ new Set();
84
+ await Promise.all(
85
+ Object.keys(projectGraph.nodes).map(async (node) => {
86
+ const projectNode = projectGraph.nodes[node];
87
+ if (!_optionalChain([projectNode, 'optionalAccess', _ => _.data, 'access', _2 => _2.root])) {
88
+ return;
89
+ }
90
+ const projectPackageJsonPath = _chunkCQDBLKPFjs.joinPaths.call(void 0,
91
+ workspaceRoot,
92
+ projectNode.data.root,
93
+ "package.json"
94
+ );
95
+ if (!_fs.existsSync.call(void 0, projectPackageJsonPath)) {
96
+ return;
97
+ }
98
+ const projectPackageJson = JSON.parse(
99
+ await _promises.readFile.call(void 0, projectPackageJsonPath, "utf8")
100
+ );
101
+ if (projectPackageJson.private === true && projectPackageJson.name) {
102
+ privatePackages.add(projectPackageJson.name);
103
+ }
104
+ })
105
+ );
106
+ return privatePackages;
107
+ }
108
+ function stripPrivateWorkspaceDepsFromPackageJson(packageJson, privatePackages) {
109
+ const removed = [];
110
+ for (const field of PACKAGE_JSON_DEP_FIELDS) {
111
+ const deps = packageJson[field];
112
+ if (!deps || typeof deps !== "object") {
113
+ continue;
114
+ }
115
+ for (const [name, version] of Object.entries(deps)) {
116
+ if (typeof version === "string" && version.startsWith("workspace:") && privatePackages.has(name)) {
117
+ delete deps[name];
118
+ removed.push(`${field}.${name}`);
119
+ }
120
+ }
121
+ if (Object.keys(deps).length === 0) {
122
+ delete packageJson[field];
123
+ }
124
+ }
125
+ return removed;
126
+ }
127
+ async function stripPrivateWorkspaceDeps(packageRoot, workspaceRoot) {
128
+ const packageJsonPath = _chunkCQDBLKPFjs.joinPaths.call(void 0, packageRoot, "package.json");
129
+ const packageJson = JSON.parse(
130
+ await _promises.readFile.call(void 0, packageJsonPath, "utf8")
131
+ );
132
+ const privatePackages = await getPrivateWorkspacePackageNames(workspaceRoot);
133
+ const removed = stripPrivateWorkspaceDepsFromPackageJson(
134
+ packageJson,
135
+ privatePackages
136
+ );
137
+ if (removed.length === 0) {
138
+ return removed;
139
+ }
140
+ await _promises.writeFile.call(void 0,
141
+ packageJsonPath,
142
+ await _prettier.format.call(void 0, JSON.stringify(packageJson), PACKAGE_JSON_FORMAT_OPTIONS)
143
+ );
144
+ return removed;
145
+ }
146
+ async function addPackageJsonGitHead(packageRoot) {
147
+ const packageJsonPath = _chunkCQDBLKPFjs.joinPaths.call(void 0, packageRoot, "package.json");
148
+ if (!packageJsonPath) {
149
+ throw new Error(
150
+ "No file path provided. Please provide a valid path to the package.json file."
151
+ );
152
+ }
153
+ const packageJsonValue = JSON.parse(await _promises.readFile.call(void 0, packageJsonPath, "utf8"));
154
+ if (!packageJsonValue || typeof packageJsonValue !== "object") {
155
+ throw new Error(
156
+ `Invalid package.json file at ${packageJsonPath}. Please ensure it is a valid JSON file.`
157
+ );
158
+ }
159
+ const gitHead = _child_process.execFileSync.call(void 0, "git", ["rev-parse", "HEAD"], {
160
+ cwd: _path.dirname.call(void 0, _path.resolve.call(void 0, packageJsonPath)),
161
+ encoding: "utf8"
162
+ }).trim();
163
+ packageJsonValue.gitHead = gitHead;
164
+ return _promises.writeFile.call(void 0,
165
+ packageJsonPath,
166
+ await _prettier.format.call(void 0, JSON.stringify(packageJsonValue), PACKAGE_JSON_FORMAT_OPTIONS)
167
+ );
168
+ }
169
+
170
+
171
+
172
+
173
+
174
+
175
+ exports.PackageManagerTypes = PackageManagerTypes; exports.getPackageInfo = getPackageInfo; exports.stripPrivateWorkspaceDeps = stripPrivateWorkspaceDeps; exports.addPackageJsonGitHead = addPackageJsonGitHead;
@@ -4,10 +4,11 @@ export { C as CargoClippyExecutorSchema, c as cargoClippyExecutor } from './exec
4
4
  export { C as CargoDocExecutorSchema, c as cargoDocExecutor } from './executor-DpEbHA1f.mjs';
5
5
  export { C as CargoFormatExecutorSchema, c as cargoFormatExecutor } from './executor-CVgzIGPj.mjs';
6
6
  export { C as CargoPublishExecutorSchema, g as getRegistryVersion } from './executor-jYQ7uQ13.mjs';
7
+ export { C as CommandPublishExecutorSchema } from './schema.d-vPuQzus3.mjs';
7
8
  export { C as CleanPackageExecutorSchema } from './schema.d-B9y7rRms.mjs';
8
9
  export { E as ESBuildExecutorSchema, e as esbuildExecutorFn } from './executor-Bvhe30H9.mjs';
9
10
  export { N as NapiExecutorSchema, n as napiExecutor } from './executor-DGBYJ2e9.mjs';
10
- export { L as LARGE_BUFFER, N as NpmPublishExecutorSchema } from './executor-BF7_LjrR.mjs';
11
+ export { N as NpmPublishExecutorSchema } from './schema.d-Muf2toJ0.mjs';
11
12
  export { S as SizeLimitExecutorSchema, s as sizeLimitExecutorFn } from './executor-gZ6drqad.mjs';
12
13
  export { T as TSDownExecutorSchema, t as tsdownExecutorFn } from './executor-CfRFawOI.mjs';
13
14
  export { T as TypiaExecutorSchema, t as typiaExecutorFn } from './executor-ByqK10v5.mjs';
@@ -4,10 +4,11 @@ export { C as CargoClippyExecutorSchema, c as cargoClippyExecutor } from './exec
4
4
  export { C as CargoDocExecutorSchema, c as cargoDocExecutor } from './executor-DpEbHA1f.js';
5
5
  export { C as CargoFormatExecutorSchema, c as cargoFormatExecutor } from './executor-CVgzIGPj.js';
6
6
  export { C as CargoPublishExecutorSchema, g as getRegistryVersion } from './executor-jYQ7uQ13.js';
7
+ export { C as CommandPublishExecutorSchema } from './schema.d-vPuQzus3.js';
7
8
  export { C as CleanPackageExecutorSchema } from './schema.d-B9y7rRms.js';
8
9
  export { E as ESBuildExecutorSchema, e as esbuildExecutorFn } from './executor-Bvhe30H9.js';
9
10
  export { N as NapiExecutorSchema, n as napiExecutor } from './executor-DGBYJ2e9.js';
10
- export { L as LARGE_BUFFER, N as NpmPublishExecutorSchema } from './executor-BF7_LjrR.js';
11
+ export { N as NpmPublishExecutorSchema } from './schema.d-Muf2toJ0.js';
11
12
  export { S as SizeLimitExecutorSchema, s as sizeLimitExecutorFn } from './executor-gZ6drqad.js';
12
13
  export { T as TSDownExecutorSchema, t as tsdownExecutorFn } from './executor-CfRFawOI.js';
13
14
  export { T as TypiaExecutorSchema, t as typiaExecutorFn } from './executor-ByqK10v5.js';