@storm-software/workspace-tools 1.296.115 → 1.297.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.
- package/dist/{chunk-6QGYUCID.mjs → chunk-2Z34TDPM.mjs} +3 -4
- package/dist/{chunk-RU4TNHFG.js → chunk-3AHXYCKA.js} +1 -2
- package/dist/chunk-52ZDVDIY.mjs +84 -0
- package/dist/{chunk-A3ELSD3U.js → chunk-HKZ7DBR7.js} +1 -2
- package/dist/chunk-KCQIASWP.js +84 -0
- package/dist/chunk-N55FJ7J3.mjs +328 -0
- package/dist/{chunk-K6UOPTIZ.mjs → chunk-QQ64FCAP.mjs} +1 -2
- package/dist/chunk-QSQTOZGN.js +328 -0
- package/dist/executors.d.mts +2 -1
- package/dist/executors.d.ts +2 -1
- package/dist/executors.js +9 -11
- package/dist/executors.mjs +9 -11
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +12 -14
- package/dist/index.mjs +12 -14
- package/dist/{executor-BF7_LjrR.d.mts → schema.d-Muf2toJ0.d.mts} +1 -8
- package/dist/{executor-BF7_LjrR.d.ts → schema.d-Muf2toJ0.d.ts} +1 -8
- package/dist/schema.d-vPuQzus3.d.mts +41 -0
- package/dist/schema.d-vPuQzus3.d.ts +41 -0
- package/dist/src/executors/cargo-publish/executor.js +2 -2
- package/dist/src/executors/cargo-publish/executor.mjs +1 -1
- package/dist/src/executors/command-publish/executor.d.mts +8 -0
- package/dist/src/executors/command-publish/executor.d.ts +8 -0
- package/dist/src/executors/command-publish/executor.js +7 -0
- package/dist/src/executors/command-publish/executor.mjs +8 -0
- package/dist/src/executors/command-publish/schema.d.ts +41 -0
- package/dist/src/executors/command-publish/schema.json +52 -0
- package/dist/src/executors/command-publish/untyped.d.mts +5 -0
- package/dist/src/executors/command-publish/untyped.d.ts +5 -0
- package/dist/src/executors/command-publish/untyped.js +46 -0
- package/dist/src/executors/command-publish/untyped.mjs +48 -0
- package/dist/src/executors/npm-publish/executor.d.mts +8 -2
- package/dist/src/executors/npm-publish/executor.d.ts +8 -2
- package/dist/src/executors/npm-publish/executor.js +2 -4
- package/dist/src/executors/npm-publish/executor.mjs +1 -3
- package/docs/api/executors/command-publish/schema.md +43 -0
- package/executors.json +5 -0
- package/package.json +12 -12
- /package/dist/{chunk-GHQJKIMQ.mjs → chunk-OYOYESMB.mjs} +0 -0
- /package/dist/{chunk-P6HSE7LH.js → chunk-TEX5JJNH.js} +0 -0
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getWorkspacePackageManager
|
|
3
|
-
} from "./chunk-EXRSULNO.mjs";
|
|
4
1
|
import {
|
|
5
2
|
getGitHubTools
|
|
6
3
|
} from "./chunk-SHJC4UVH.mjs";
|
|
@@ -8,6 +5,9 @@ import {
|
|
|
8
5
|
addPackageJsonGitHead,
|
|
9
6
|
stripPrivateWorkspaceDeps
|
|
10
7
|
} from "./chunk-G4DPDEL3.mjs";
|
|
8
|
+
import {
|
|
9
|
+
getWorkspacePackageManager
|
|
10
|
+
} from "./chunk-EXRSULNO.mjs";
|
|
11
11
|
import {
|
|
12
12
|
getConfig
|
|
13
13
|
} from "./chunk-I4KVL3GR.mjs";
|
|
@@ -324,6 +324,5 @@ Error: ${JSON.stringify(
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
export {
|
|
327
|
-
LARGE_BUFFER,
|
|
328
327
|
npmPublishExecutorFn
|
|
329
328
|
};
|
|
@@ -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:
|
|
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,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;
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWorkspacePackageManager
|
|
3
|
+
} from "./chunk-EXRSULNO.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getGitHubTools
|
|
6
|
+
} from "./chunk-SHJC4UVH.mjs";
|
|
7
|
+
import {
|
|
8
|
+
addPackageJsonGitHead,
|
|
9
|
+
stripPrivateWorkspaceDeps
|
|
10
|
+
} from "./chunk-G4DPDEL3.mjs";
|
|
11
|
+
import {
|
|
12
|
+
getConfig
|
|
13
|
+
} from "./chunk-I4KVL3GR.mjs";
|
|
14
|
+
import {
|
|
15
|
+
joinPaths
|
|
16
|
+
} from "./chunk-TBW5MCN6.mjs";
|
|
17
|
+
|
|
18
|
+
// src/executors/npm-publish/executor.ts
|
|
19
|
+
import { createJiti } from "jiti";
|
|
20
|
+
import { execSync } from "node:child_process";
|
|
21
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
22
|
+
import { format } from "prettier";
|
|
23
|
+
import prettierPlugin from "prettier-plugin-packagejson";
|
|
24
|
+
var LARGE_BUFFER = 1024 * 1e6;
|
|
25
|
+
async function replaceDepsAliases(jiti, packageRoot, workspaceRoot, packageManager) {
|
|
26
|
+
if (packageManager === "bun") {
|
|
27
|
+
const { replaceDepsAliases: replaceBunDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/bun-tools"));
|
|
28
|
+
return replaceBunDepsAliases(packageRoot, workspaceRoot);
|
|
29
|
+
}
|
|
30
|
+
if (packageManager === "pnpm") {
|
|
31
|
+
const { replaceDepsAliases: replacePnpmDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/pnpm-tools"));
|
|
32
|
+
return replacePnpmDepsAliases(packageRoot, workspaceRoot);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function npmPublishExecutorFn(options, context) {
|
|
36
|
+
const workspaceConfig = await getConfig(context.root);
|
|
37
|
+
const packageManager = await getWorkspacePackageManager(
|
|
38
|
+
context.root,
|
|
39
|
+
workspaceConfig
|
|
40
|
+
);
|
|
41
|
+
const github = await getGitHubTools(workspaceConfig);
|
|
42
|
+
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
43
|
+
if (!context.projectName) {
|
|
44
|
+
github.error("The `npm-publish` executor requires a `projectName`.");
|
|
45
|
+
return { success: false };
|
|
46
|
+
}
|
|
47
|
+
const projectConfig = context.projectsConfigurations?.projects?.[context.projectName];
|
|
48
|
+
if (!projectConfig) {
|
|
49
|
+
github.error(
|
|
50
|
+
`Could not find project configuration for \`${context.projectName}\``
|
|
51
|
+
);
|
|
52
|
+
return { success: false };
|
|
53
|
+
}
|
|
54
|
+
const packageRoot = joinPaths(
|
|
55
|
+
context.root,
|
|
56
|
+
options.packageRoot || joinPaths("dist", projectConfig.root)
|
|
57
|
+
);
|
|
58
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName]?.root ? joinPaths(
|
|
59
|
+
context.root,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
+
context.projectsConfigurations.projects[context.projectName].root
|
|
62
|
+
) : packageRoot;
|
|
63
|
+
const jiti = createJiti(context.root, {
|
|
64
|
+
fsCache: joinPaths(context.root, "node_modules/.cache/storm", "jiti"),
|
|
65
|
+
interopDefault: true
|
|
66
|
+
});
|
|
67
|
+
const { getNpmRegistry, getRegistry } = await jiti.import(jiti.esmResolve("@storm-software/npm-tools/helpers"));
|
|
68
|
+
const packageJsonPath = joinPaths(packageRoot, "package.json");
|
|
69
|
+
const packageJsonFile = await readFile(packageJsonPath, "utf8");
|
|
70
|
+
if (!packageJsonFile) {
|
|
71
|
+
github.error(`Could not find \`package.json\` at ${packageJsonPath}`);
|
|
72
|
+
return { success: false };
|
|
73
|
+
}
|
|
74
|
+
const packageJson = JSON.parse(packageJsonFile);
|
|
75
|
+
const projectPackageJsonPath = joinPaths(projectRoot, "package.json");
|
|
76
|
+
const projectPackageJsonFile = await readFile(projectPackageJsonPath, "utf8");
|
|
77
|
+
if (!projectPackageJsonFile) {
|
|
78
|
+
github.error(
|
|
79
|
+
`Could not find \`package.json\` at ${projectPackageJsonPath}`
|
|
80
|
+
);
|
|
81
|
+
return { success: false };
|
|
82
|
+
}
|
|
83
|
+
const projectPackageJson = JSON.parse(projectPackageJsonFile);
|
|
84
|
+
if (packageJson.version !== projectPackageJson.version) {
|
|
85
|
+
console.warn(
|
|
86
|
+
`The version in the package.json file at ${packageJsonPath} (current: ${packageJson.version}) does not match the version in the package.json file at ${projectPackageJsonPath} (current: ${projectPackageJson.version}). This file will be updated to match the version in the project package.json file.`
|
|
87
|
+
);
|
|
88
|
+
if (projectPackageJson.version) {
|
|
89
|
+
packageJson.version = projectPackageJson.version;
|
|
90
|
+
await writeFile(
|
|
91
|
+
packageJsonPath,
|
|
92
|
+
await format(JSON.stringify(packageJson), {
|
|
93
|
+
parser: "json",
|
|
94
|
+
proseWrap: "preserve",
|
|
95
|
+
trailingComma: "none",
|
|
96
|
+
tabWidth: 2,
|
|
97
|
+
semi: true,
|
|
98
|
+
singleQuote: false,
|
|
99
|
+
quoteProps: "as-needed",
|
|
100
|
+
insertPragma: false,
|
|
101
|
+
bracketSameLine: true,
|
|
102
|
+
printWidth: 80,
|
|
103
|
+
bracketSpacing: true,
|
|
104
|
+
arrowParens: "avoid",
|
|
105
|
+
endOfLine: "lf",
|
|
106
|
+
plugins: [prettierPlugin]
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const packageName = packageJson.name;
|
|
112
|
+
console.info(
|
|
113
|
+
`\u{1F680} Running Storm NPM Publish executor on the ${packageName} package`
|
|
114
|
+
);
|
|
115
|
+
const packageTxt = packageName === context.projectName ? `package "${packageName}"` : `package "${packageName}" from project "${context.projectName}"`;
|
|
116
|
+
if (packageJson.private === true) {
|
|
117
|
+
console.warn(
|
|
118
|
+
`Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`
|
|
119
|
+
);
|
|
120
|
+
return { success: true };
|
|
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
|
+
}
|
|
131
|
+
await replaceDepsAliases(jiti, packageRoot, context.root, packageManager);
|
|
132
|
+
await addPackageJsonGitHead(packageRoot);
|
|
133
|
+
const npmPublishCommandSegments = [`npm publish --json`];
|
|
134
|
+
const npmViewCommandSegments = [
|
|
135
|
+
`npm view ${packageName} versions dist-tags --json`
|
|
136
|
+
];
|
|
137
|
+
const registry = await Promise.resolve(
|
|
138
|
+
options.registry ?? (await getRegistry() || getNpmRegistry())
|
|
139
|
+
);
|
|
140
|
+
if (registry) {
|
|
141
|
+
npmPublishCommandSegments.push(`--registry="${registry}" `);
|
|
142
|
+
npmViewCommandSegments.push(`--registry="${registry}" `);
|
|
143
|
+
}
|
|
144
|
+
if (options.otp) {
|
|
145
|
+
npmPublishCommandSegments.push(`--otp="${options.otp}" `);
|
|
146
|
+
}
|
|
147
|
+
let token;
|
|
148
|
+
if (!options.otp && registry) {
|
|
149
|
+
token = await github.getIDToken(
|
|
150
|
+
`npm:${registry.replace(/^https?:\/\//, "")}`
|
|
151
|
+
);
|
|
152
|
+
if (!token) {
|
|
153
|
+
github.warning(
|
|
154
|
+
`Either a One time password (OTP) or an OpenID Connect (OIDC) token is generally required to publish ${packageTxt} to NPM. Usually the OIDC token should be provided automatically via GitHub Actions (see: https://github.com/actions/toolkit/tree/main/packages/core#oidc-token); however, the release process was unable to retrieve it. Please provide a \`otp\` executor option, or investigate why the OIDC token could not be retrieved.`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
npmPublishCommandSegments.push("--provenance --access=public ");
|
|
159
|
+
if (isDryRun) {
|
|
160
|
+
npmPublishCommandSegments.push("--dry-run");
|
|
161
|
+
}
|
|
162
|
+
const tag = options.tag || execSync("npm config get tag", {
|
|
163
|
+
cwd: packageRoot,
|
|
164
|
+
env: {
|
|
165
|
+
NPM_ID_TOKEN: token ? token : void 0,
|
|
166
|
+
...process.env,
|
|
167
|
+
FORCE_COLOR: "true"
|
|
168
|
+
},
|
|
169
|
+
maxBuffer: LARGE_BUFFER,
|
|
170
|
+
killSignal: "SIGTERM"
|
|
171
|
+
}).toString().trim();
|
|
172
|
+
if (tag) {
|
|
173
|
+
npmPublishCommandSegments.push(`--tag="${tag}" `);
|
|
174
|
+
}
|
|
175
|
+
if (!isDryRun) {
|
|
176
|
+
const currentVersion = options.version || packageJson.version;
|
|
177
|
+
try {
|
|
178
|
+
try {
|
|
179
|
+
const result = execSync(npmViewCommandSegments.join(" "), {
|
|
180
|
+
cwd: packageRoot,
|
|
181
|
+
env: {
|
|
182
|
+
NPM_ID_TOKEN: token,
|
|
183
|
+
...process.env,
|
|
184
|
+
FORCE_COLOR: "true"
|
|
185
|
+
},
|
|
186
|
+
maxBuffer: LARGE_BUFFER,
|
|
187
|
+
killSignal: "SIGTERM"
|
|
188
|
+
});
|
|
189
|
+
const resultJson = JSON.parse(result.toString());
|
|
190
|
+
const distTags = resultJson["dist-tags"] || {};
|
|
191
|
+
if (distTags[tag] === currentVersion) {
|
|
192
|
+
console.warn(
|
|
193
|
+
`Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`
|
|
194
|
+
);
|
|
195
|
+
return { success: true };
|
|
196
|
+
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
console.debug(
|
|
199
|
+
`An error occurred while checking for existing dist-tags. Please note: if this is the first time this package has been published to npm, this can be ignored.
|
|
200
|
+
|
|
201
|
+
Error: ${JSON.stringify(
|
|
202
|
+
err,
|
|
203
|
+
null,
|
|
204
|
+
2
|
|
205
|
+
)}`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
if (!isDryRun) {
|
|
210
|
+
const command = `npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry="${registry}" `;
|
|
211
|
+
console.debug(
|
|
212
|
+
`Adding the dist-tag ${tag} - preparing to run the following: ${command}`
|
|
213
|
+
);
|
|
214
|
+
const result = execSync(command, {
|
|
215
|
+
cwd: packageRoot,
|
|
216
|
+
env: {
|
|
217
|
+
NPM_ID_TOKEN: token,
|
|
218
|
+
...process.env,
|
|
219
|
+
FORCE_COLOR: "true"
|
|
220
|
+
},
|
|
221
|
+
maxBuffer: LARGE_BUFFER,
|
|
222
|
+
killSignal: "SIGTERM"
|
|
223
|
+
});
|
|
224
|
+
console.info(
|
|
225
|
+
`Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}".
|
|
226
|
+
|
|
227
|
+
Execution response: ${result.toString()}`
|
|
228
|
+
);
|
|
229
|
+
} else {
|
|
230
|
+
console.info(
|
|
231
|
+
`Would have added the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
|
|
232
|
+
`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
return { success: true };
|
|
236
|
+
} catch (err) {
|
|
237
|
+
try {
|
|
238
|
+
const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
|
|
239
|
+
if (stdoutData?.error && !(stdoutData.error?.code?.includes("E404") && stdoutData.error?.summary?.includes("no such package available")) && !(err.stderr?.toString().includes("E404") && err.stderr?.toString().includes("no such package available"))) {
|
|
240
|
+
const errorMessage = `An unexpected error occured while running the npm dist-tag add command:
|
|
241
|
+
|
|
242
|
+
${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
|
|
243
|
+
` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
|
|
244
|
+
` : ""}`;
|
|
245
|
+
github.error(errorMessage);
|
|
246
|
+
return { success: false };
|
|
247
|
+
}
|
|
248
|
+
} catch (err2) {
|
|
249
|
+
const stdoutData = JSON.parse(err2.stdout?.toString() || "{}");
|
|
250
|
+
const errorMessage = `An unexpected error occured while processing the npm dist-tag add output:
|
|
251
|
+
|
|
252
|
+
${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
|
|
253
|
+
` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
|
|
254
|
+
` : ""}`;
|
|
255
|
+
github.error(errorMessage);
|
|
256
|
+
return { success: false };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
} catch (err) {
|
|
260
|
+
const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
|
|
261
|
+
if (!(stdoutData.error?.code?.includes("E404") && stdoutData.error?.summary?.toLowerCase().includes("not found")) && !(err.stderr?.toString().includes("E404") && err.stderr?.toString().toLowerCase().includes("not found"))) {
|
|
262
|
+
const errorMessage = `An unexpected error occured while checking for existing dist-tags:
|
|
263
|
+
|
|
264
|
+
${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
|
|
265
|
+
` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
|
|
266
|
+
` : ""}`;
|
|
267
|
+
github.error(errorMessage);
|
|
268
|
+
return { success: false };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const cwd = packageRoot;
|
|
274
|
+
const command = npmPublishCommandSegments.join(" ");
|
|
275
|
+
console.info(
|
|
276
|
+
`Running publish command "${command}" in current working directory: "${cwd}" `
|
|
277
|
+
);
|
|
278
|
+
const result = execSync(command, {
|
|
279
|
+
cwd,
|
|
280
|
+
env: {
|
|
281
|
+
NPM_ID_TOKEN: token,
|
|
282
|
+
...process.env,
|
|
283
|
+
FORCE_COLOR: "true"
|
|
284
|
+
},
|
|
285
|
+
maxBuffer: LARGE_BUFFER,
|
|
286
|
+
killSignal: "SIGTERM"
|
|
287
|
+
});
|
|
288
|
+
if (isDryRun) {
|
|
289
|
+
console.info(
|
|
290
|
+
`Would publish tag "${tag}" to ${registry}, but [dry-run] was set. ${result ? `
|
|
291
|
+
|
|
292
|
+
Execution response: ${result.toString()}` : ""}`
|
|
293
|
+
);
|
|
294
|
+
} else {
|
|
295
|
+
console.info(
|
|
296
|
+
`Published tag "${tag}" to ${registry}. ${result ? `
|
|
297
|
+
|
|
298
|
+
Execution response: ${result.toString()}` : ""}`
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
return { success: true };
|
|
302
|
+
} catch (err) {
|
|
303
|
+
try {
|
|
304
|
+
const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
|
|
305
|
+
const errorMessage = `An error occurred while publishing the npm package:
|
|
306
|
+
|
|
307
|
+
${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
|
|
308
|
+
` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
|
|
309
|
+
` : ""}`;
|
|
310
|
+
github.error(errorMessage);
|
|
311
|
+
return { success: false };
|
|
312
|
+
} catch (err2) {
|
|
313
|
+
const errorMessage = `Something unexpected went wrong when processing the npm publish output.
|
|
314
|
+
|
|
315
|
+
Error: ${JSON.stringify(
|
|
316
|
+
Buffer.isBuffer(err2) ? err2.toString() : err2,
|
|
317
|
+
null,
|
|
318
|
+
2
|
|
319
|
+
)}`;
|
|
320
|
+
github.error(errorMessage);
|
|
321
|
+
return { success: false };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export {
|
|
327
|
+
npmPublishExecutorFn
|
|
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:
|
|
58
|
+
maxBuffer: 1024 * 1e6,
|
|
60
59
|
env: {
|
|
61
60
|
...process.env,
|
|
62
61
|
FORCE_COLOR: "true"
|