nx 21.0.0-canary.20250430-07b881d → 21.0.0-rc.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 (59) hide show
  1. package/migrations.json +10 -5
  2. package/package.json +14 -11
  3. package/release/changelog-renderer/index.d.ts +7 -7
  4. package/release/changelog-renderer/index.js +12 -31
  5. package/schemas/nx-schema.json +3 -3
  6. package/src/command-line/format/command-object.js +1 -1
  7. package/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  8. package/src/command-line/migrate/migrate-ui-api.js +4 -3
  9. package/src/command-line/nx-commands.d.ts +1 -1
  10. package/src/command-line/nx-commands.js +1 -1
  11. package/src/command-line/release/changelog.d.ts +3 -2
  12. package/src/command-line/release/changelog.js +57 -70
  13. package/src/command-line/release/command-object.d.ts +1 -1
  14. package/src/command-line/release/config/config.d.ts +8 -1
  15. package/src/command-line/release/config/config.js +18 -11
  16. package/src/command-line/release/release.js +30 -18
  17. package/src/command-line/release/utils/git.d.ts +1 -0
  18. package/src/command-line/release/utils/git.js +27 -8
  19. package/src/command-line/release/utils/remote-release-clients/github.d.ts +57 -0
  20. package/src/command-line/release/utils/remote-release-clients/github.js +309 -0
  21. package/src/command-line/release/utils/remote-release-clients/gitlab.d.ts +62 -0
  22. package/src/command-line/release/utils/remote-release-clients/gitlab.js +271 -0
  23. package/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +111 -0
  24. package/src/command-line/release/utils/remote-release-clients/remote-release-client.js +136 -0
  25. package/src/command-line/report/report.js +1 -29
  26. package/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  27. package/src/command-line/yargs-utils/shared-options.js +49 -17
  28. package/src/config/nx-json.d.ts +8 -1
  29. package/src/core/graph/main.js +1 -1
  30. package/src/core/graph/styles.css +1 -1
  31. package/src/daemon/server/watcher.js +0 -6
  32. package/src/executors/run-commands/running-tasks.js +15 -5
  33. package/src/generators/utils/nx-json.d.ts +1 -2
  34. package/src/generators/utils/nx-json.js +6 -12
  35. package/src/migrations/update-21-0-0/release-changelog-config-changes.d.ts +2 -0
  36. package/src/migrations/update-21-0-0/release-changelog-config-changes.js +38 -0
  37. package/src/native/index.d.ts +8 -3
  38. package/src/native/native-bindings.js +1 -0
  39. package/src/native/native-file-cache-location.js +2 -1
  40. package/src/native/nx.wasm32-wasi.wasm +0 -0
  41. package/src/project-graph/plugins/get-plugins.js +19 -14
  42. package/src/tasks-runner/forked-process-task-runner.js +1 -0
  43. package/src/tasks-runner/is-tui-enabled.d.ts +16 -1
  44. package/src/tasks-runner/is-tui-enabled.js +48 -30
  45. package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
  46. package/src/tasks-runner/pseudo-terminal.js +2 -2
  47. package/src/tasks-runner/run-command.js +3 -3
  48. package/src/tasks-runner/running-tasks/node-child-process.d.ts +1 -0
  49. package/src/tasks-runner/running-tasks/node-child-process.js +7 -0
  50. package/src/tasks-runner/task-orchestrator.js +6 -3
  51. package/src/utils/ignore.d.ts +0 -6
  52. package/src/utils/ignore.js +0 -63
  53. package/src/utils/is-ci.d.ts +1 -1
  54. package/src/utils/is-ci.js +4 -1
  55. package/src/utils/package-manager.d.ts +1 -0
  56. package/src/utils/package-manager.js +29 -16
  57. package/src/utils/params.js +22 -16
  58. package/src/command-line/release/utils/github.d.ts +0 -32
  59. package/src/command-line/release/utils/github.js +0 -326
@@ -1,48 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isTuiEnabled = isTuiEnabled;
4
- const devkit_internals_1 = require("../devkit-internals");
4
+ exports.shouldUseTui = shouldUseTui;
5
+ const native_1 = require("../native");
5
6
  const is_ci_1 = require("../utils/is-ci");
6
7
  let tuiEnabled = undefined;
7
- function isTuiEnabled(nxJson, skipCapableCheck = false) {
8
- if (tuiEnabled !== undefined) {
9
- return tuiEnabled;
10
- }
8
+ /**
9
+ * @returns If tui is enabled
10
+ */
11
+ function isTuiEnabled() {
12
+ return process.env.NX_TUI === 'true';
13
+ }
14
+ /**
15
+ * Determines if the TUI should be enabled for the current environment.
16
+ *
17
+ * **Note:** This function should almost never be called directly. Instead, use the `isTuiEnabled` function.
18
+ *
19
+ * @param nxJson `nx.json`
20
+ * @param nxArgs CLI Flags passed into Nx
21
+ * @param skipCapabilityCheck Mainly used for unit tests.
22
+ * @returns `true` if the TUI should be enabled, `false` otherwise.
23
+ */
24
+ function shouldUseTui(nxJson, nxArgs, skipCapabilityCheck = process.env.NX_TUI_SKIP_CAPABILITY_CHECK === 'true') {
11
25
  // If the current terminal/environment is not capable of displaying the TUI, we don't run it
12
26
  const isWindows = process.platform === 'win32';
13
- const isCapable = skipCapableCheck || (process.stderr.isTTY && isUnicodeSupported());
27
+ const isCapable = skipCapabilityCheck || (process.stderr.isTTY && isUnicodeSupported());
14
28
  if (!isCapable) {
15
- tuiEnabled = false;
16
- process.env.NX_TUI = 'false';
17
- return tuiEnabled;
29
+ return false;
18
30
  }
19
- // The environment variable takes precedence over the nx.json config
20
- if (typeof process.env.NX_TUI === 'string') {
21
- tuiEnabled = process.env.NX_TUI === 'true';
22
- return tuiEnabled;
31
+ if (['static', 'stream', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
32
+ // If the user has specified a non-TUI output style, we disable the TUI
33
+ return false;
23
34
  }
24
- // Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
25
- // TODO(@JamesHenry): Remove this check once Windows issues are fixed.
26
- if ((0, is_ci_1.isCI)() || isWindows) {
27
- tuiEnabled = false;
28
- process.env.NX_TUI = 'false';
29
- return tuiEnabled;
35
+ if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
36
+ return true;
30
37
  }
31
- // Only read from disk if nx.json config is not already provided (and we have not been able to determine tuiEnabled based on the above checks)
32
- if (!nxJson) {
33
- nxJson = (0, devkit_internals_1.readNxJsonFromDisk)();
38
+ // The environment variable takes precedence over the nx.json config, but
39
+ // are lower priority than the CLI args as they are less likely to change
40
+ // between runs, whereas the CLI args are specified by the user for each run.
41
+ if (typeof process.env.NX_TUI === 'string') {
42
+ return process.env.NX_TUI === 'true';
43
+ }
44
+ // BELOW THIS LINE ARE "repo specific" checks, instead of "user specific" checks.
45
+ // "user specific" checks are specified by the current user rather than the repo
46
+ // settings which are applied for all users of the repo... so they are more specific
47
+ // and take priority.
48
+ if (
49
+ // Interactive TUI doesn't make sense on CI
50
+ (0, is_ci_1.isCI)() ||
51
+ // TODO(@JamesHenry): Remove this check once Windows issues are fixed.
52
+ // Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
53
+ isWindows ||
54
+ // WASM needs further testing
55
+ native_1.IS_WASM) {
56
+ return false;
34
57
  }
35
58
  // Respect user config
36
59
  if (typeof nxJson.tui?.enabled === 'boolean') {
37
- tuiEnabled = Boolean(nxJson.tui?.enabled);
38
- }
39
- else {
40
- // Default to enabling the TUI if the system is capable of displaying it
41
- tuiEnabled = true;
60
+ return Boolean(nxJson.tui?.enabled);
42
61
  }
43
- // Also set the environment variable for consistency and ease of checking on the rust side, for example
44
- process.env.NX_TUI = tuiEnabled.toString();
45
- return tuiEnabled;
62
+ // Default to enabling the TUI if the system is capable of displaying it
63
+ return true;
46
64
  }
47
65
  // Credit to https://github.com/sindresorhus/is-unicode-supported/blob/e0373335038856c63034c8eef6ac43ee3827a601/index.js
48
66
  function isUnicodeSupported() {
@@ -20,11 +20,12 @@ export declare class PseudoTerminal {
20
20
  quiet?: boolean;
21
21
  tty?: boolean;
22
22
  }): PseudoTtyProcess;
23
- fork(id: string, script: string, { cwd, execArgv, jsEnv, quiet, }: {
23
+ fork(id: string, script: string, { cwd, execArgv, jsEnv, quiet, commandLabel, }: {
24
24
  cwd?: string;
25
25
  execArgv?: string[];
26
26
  jsEnv?: Record<string, string>;
27
27
  quiet?: boolean;
28
+ commandLabel?: string;
28
29
  }): Promise<PseudoTtyProcessWithSend>;
29
30
  sendMessageToChildren(message: Serializable): void;
30
31
  onMessageFromChildren(callback: (message: Serializable) => void): void;
@@ -63,11 +63,11 @@ class PseudoTerminal {
63
63
  this.childProcesses.add(cp);
64
64
  return cp;
65
65
  }
66
- async fork(id, script, { cwd, execArgv, jsEnv, quiet, }) {
66
+ async fork(id, script, { cwd, execArgv, jsEnv, quiet, commandLabel, }) {
67
67
  if (!this.initialized) {
68
68
  throw new Error('Call init() before forking processes');
69
69
  }
70
- const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
70
+ const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet, commandLabel), id, this.pseudoIPC);
71
71
  this.childProcesses.add(cp);
72
72
  await this.pseudoIPC.waitForChildReady(id);
73
73
  return cp;
@@ -47,7 +47,8 @@ const originalConsoleError = console.error.bind(console);
47
47
  async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides) {
48
48
  const overridesWithoutHidden = { ...overrides };
49
49
  delete overridesWithoutHidden['__overrides_unparsed__'];
50
- if ((0, is_tui_enabled_1.isTuiEnabled)(nxJson)) {
50
+ const isRunOne = initiatingProject != null;
51
+ if ((0, is_tui_enabled_1.isTuiEnabled)()) {
51
52
  const interceptedNxCloudLogs = [];
52
53
  const createPatchedConsoleMethod = (originalMethod) => {
53
54
  return (...args) => {
@@ -124,7 +125,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
124
125
  const lifeCycles = [tsLifeCycle];
125
126
  // Only run the TUI if there are tasks to run
126
127
  if (tasks.length > 0) {
127
- appLifeCycle = new AppLifeCycle(tasks, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
128
+ appLifeCycle = new AppLifeCycle(tasks, initiatingTasks.map((t) => t.id), isRunOne ? 0 /* RunMode.RunOne */ : 1 /* RunMode.RunMany */, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
128
129
  lifeCycles.unshift(appLifeCycle);
129
130
  /**
130
131
  * Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
@@ -205,7 +206,6 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
205
206
  };
206
207
  }
207
208
  const { runnerOptions } = getRunner(nxArgs, nxJson);
208
- const isRunOne = initiatingProject != null;
209
209
  const useDynamicOutput = shouldUseDynamicLifeCycle(tasks, runnerOptions, nxArgs.outputStyle);
210
210
  if (isRunOne) {
211
211
  if (useDynamicOutput) {
@@ -4,6 +4,7 @@ export declare class NodeChildProcessWithNonDirectOutput implements RunningTask
4
4
  private childProcess;
5
5
  private terminalOutput;
6
6
  private exitCallbacks;
7
+ private exitCode;
7
8
  constructor(childProcess: ChildProcess, { streamOutput, prefix }: {
8
9
  streamOutput: boolean;
9
10
  prefix: string;
@@ -35,6 +35,7 @@ class NodeChildProcessWithNonDirectOutput {
35
35
  this.childProcess.on('exit', (code, signal) => {
36
36
  if (code === null)
37
37
  code = (0, exit_codes_1.signalToCode)(signal);
38
+ this.exitCode = code;
38
39
  for (const cb of this.exitCallbacks) {
39
40
  cb(code, this.terminalOutput);
40
41
  }
@@ -56,6 +57,12 @@ class NodeChildProcessWithNonDirectOutput {
56
57
  this.exitCallbacks.push(cb);
57
58
  }
58
59
  async getResults() {
60
+ if (typeof this.exitCode === 'number') {
61
+ return {
62
+ code: this.exitCode,
63
+ terminalOutput: this.terminalOutput,
64
+ };
65
+ }
59
66
  return new Promise((res) => {
60
67
  this.onExit((code, terminalOutput) => {
61
68
  res({ code, terminalOutput });
@@ -38,9 +38,11 @@ class TaskOrchestrator {
38
38
  this.taskGraphForHashing = taskGraphForHashing;
39
39
  this.taskDetails = (0, hash_task_1.getTaskDetails)();
40
40
  this.cache = (0, cache_1.getCache)(this.options);
41
- this.tuiEnabled = (0, is_tui_enabled_1.isTuiEnabled)(this.nxJson);
41
+ this.tuiEnabled = (0, is_tui_enabled_1.isTuiEnabled)();
42
42
  this.forkedProcessTaskRunner = new forked_process_task_runner_1.ForkedProcessTaskRunner(this.options, this.tuiEnabled);
43
- this.runningTasksService = new native_1.RunningTasksService((0, db_connection_1.getDbConnection)());
43
+ this.runningTasksService = !native_1.IS_WASM
44
+ ? new native_1.RunningTasksService((0, db_connection_1.getDbConnection)())
45
+ : null;
44
46
  this.tasksSchedule = new tasks_schedule_1.TasksSchedule(this.projectGraph, this.taskGraph, this.options);
45
47
  // region internal state
46
48
  this.batchEnv = (0, task_env_1.getEnvVariablesForBatchProcess)(this.options.skipNxCache, this.options.captureStderr);
@@ -422,7 +424,8 @@ class TaskOrchestrator {
422
424
  }
423
425
  }
424
426
  async startContinuousTask(task, groupId) {
425
- if (this.runningTasksService.getRunningTasks([task.id]).length) {
427
+ if (this.runningTasksService &&
428
+ this.runningTasksService.getRunningTasks([task.id]).length) {
426
429
  await this.preRunSteps([task], { groupId });
427
430
  if (this.tuiEnabled) {
428
431
  this.options.lifeCycle.setTaskStatus(task.id, 8 /* NativeTaskStatus.Shared */);
@@ -1,8 +1,2 @@
1
1
  import ignore from 'ignore';
2
- /**
3
- * An array of glob patterns that should always be ignored.
4
- */
5
- export declare const ALWAYS_IGNORE: string[];
6
- export declare function getIgnoredGlobs(root?: string, prependRoot?: boolean): string[];
7
- export declare function getAlwaysIgnore(root?: string): string[];
8
2
  export declare function getIgnoreObject(root?: string): ReturnType<typeof ignore>;
@@ -1,75 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALWAYS_IGNORE = void 0;
4
- exports.getIgnoredGlobs = getIgnoredGlobs;
5
- exports.getAlwaysIgnore = getAlwaysIgnore;
6
3
  exports.getIgnoreObject = getIgnoreObject;
7
- const node_fs_1 = require("node:fs");
8
4
  const ignore_1 = require("ignore");
9
5
  const fileutils_1 = require("./fileutils");
10
- const path_1 = require("./path");
11
6
  const workspace_root_1 = require("./workspace-root");
12
- /**
13
- * An array of glob patterns that should always be ignored.
14
- */
15
- exports.ALWAYS_IGNORE = getAlwaysIgnore();
16
- function getIgnoredGlobs(root = workspace_root_1.workspaceRoot, prependRoot = true) {
17
- const files = ['.gitignore', '.nxignore'];
18
- if (prependRoot) {
19
- return [
20
- ...getAlwaysIgnore(root),
21
- ...files.flatMap((f) => getIgnoredGlobsFromFile((0, path_1.joinPathFragments)(root, f), root)),
22
- ];
23
- }
24
- else {
25
- return [
26
- ...getAlwaysIgnore(),
27
- ...files.flatMap((f) => getIgnoredGlobsFromFile((0, path_1.joinPathFragments)(root, f))),
28
- ];
29
- }
30
- }
31
- function getAlwaysIgnore(root) {
32
- const paths = [
33
- 'node_modules',
34
- '**/node_modules',
35
- '.git',
36
- '.nx',
37
- '.vscode',
38
- '.yarn/cache',
39
- ];
40
- return root ? paths.map((x) => (0, path_1.joinPathFragments)(root, x)) : paths;
41
- }
42
7
  function getIgnoreObject(root = workspace_root_1.workspaceRoot) {
43
8
  const ig = (0, ignore_1.default)();
44
9
  ig.add((0, fileutils_1.readFileIfExisting)(`${root}/.gitignore`));
45
10
  ig.add((0, fileutils_1.readFileIfExisting)(`${root}/.nxignore`));
46
11
  return ig;
47
12
  }
48
- function getIgnoredGlobsFromFile(file, root) {
49
- try {
50
- const results = [];
51
- const contents = (0, node_fs_1.readFileSync)(file, 'utf-8');
52
- const lines = contents.split('\n');
53
- for (const line of lines) {
54
- const trimmed = line.trim();
55
- if (!trimmed || trimmed.startsWith('#')) {
56
- continue;
57
- }
58
- else if (trimmed.startsWith('/')) {
59
- if (root) {
60
- results.push((0, path_1.joinPathFragments)(root, trimmed));
61
- }
62
- else {
63
- results.push((0, path_1.joinPathFragments)('.', trimmed));
64
- }
65
- }
66
- else {
67
- results.push(trimmed);
68
- }
69
- }
70
- return results;
71
- }
72
- catch (e) {
73
- return [];
74
- }
75
- }
@@ -1 +1 @@
1
- export declare function isCI(): boolean;
1
+ export declare function isCI(): string | boolean;
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isCI = isCI;
4
4
  function isCI() {
5
- return ((process.env.CI && process.env.CI !== 'false') ||
5
+ if (process.env.CI === 'false') {
6
+ return false;
7
+ }
8
+ return (process.env.CI ||
6
9
  process.env.TF_BUILD === 'true' ||
7
10
  process.env.GITHUB_ACTIONS === 'true' ||
8
11
  process.env.BUILDKITE === 'true' ||
@@ -44,6 +44,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
44
44
  * but it can also be passed in explicitly.
45
45
  */
46
46
  export declare function getPackageManagerVersion(packageManager?: PackageManager, cwd?: string): string;
47
+ export declare function parseVersionFromPackageManagerField(requestedPackageManager: string, packageManagerFieldValue: string | undefined): null | string;
47
48
  /**
48
49
  * Checks for a project level npmrc file by crawling up the file tree until
49
50
  * hitting a package.json file, as this is how npm finds them as well.
@@ -4,6 +4,7 @@ exports.detectPackageManager = detectPackageManager;
4
4
  exports.isWorkspacesEnabled = isWorkspacesEnabled;
5
5
  exports.getPackageManagerCommand = getPackageManagerCommand;
6
6
  exports.getPackageManagerVersion = getPackageManagerVersion;
7
+ exports.parseVersionFromPackageManagerField = parseVersionFromPackageManagerField;
7
8
  exports.findFileInPackageJsonDirectory = findFileInPackageJsonDirectory;
8
9
  exports.modifyYarnRcYmlToFitNewDirectory = modifyYarnRcYmlToFitNewDirectory;
9
10
  exports.modifyYarnRcToFitNewDirectory = modifyYarnRcToFitNewDirectory;
@@ -175,30 +176,42 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
175
176
  */
176
177
  function getPackageManagerVersion(packageManager = detectPackageManager(), cwd = process.cwd()) {
177
178
  let version;
178
- try {
179
- version = (0, child_process_1.execSync)(`${packageManager} --version`, {
180
- cwd,
181
- encoding: 'utf-8',
182
- windowsHide: true,
183
- }).trim();
179
+ if ((0, fs_1.existsSync)((0, path_1.join)(cwd, 'package.json'))) {
180
+ const packageManagerEntry = (0, fileutils_1.readJsonFile)((0, path_1.join)(cwd, 'package.json'))?.packageManager;
181
+ version = parseVersionFromPackageManagerField(packageManager, packageManagerEntry);
184
182
  }
185
- catch {
186
- if ((0, fs_1.existsSync)((0, path_1.join)(cwd, 'package.json'))) {
187
- const packageVersion = (0, fileutils_1.readJsonFile)((0, path_1.join)(cwd, 'package.json'))?.packageManager;
188
- if (packageVersion) {
189
- const [packageManagerFromPackageJson, versionFromPackageJson] = packageVersion.split('@');
190
- if (packageManagerFromPackageJson === packageManager &&
191
- versionFromPackageJson) {
192
- version = versionFromPackageJson;
193
- }
194
- }
183
+ if (!version) {
184
+ try {
185
+ version = (0, child_process_1.execSync)(`${packageManager} --version`, {
186
+ cwd,
187
+ encoding: 'utf-8',
188
+ windowsHide: true,
189
+ }).trim();
195
190
  }
191
+ catch { }
196
192
  }
197
193
  if (!version) {
198
194
  throw new Error(`Cannot determine the version of ${packageManager}.`);
199
195
  }
200
196
  return version;
201
197
  }
198
+ function parseVersionFromPackageManagerField(requestedPackageManager, packageManagerFieldValue) {
199
+ if (!packageManagerFieldValue)
200
+ return null;
201
+ const [packageManagerFromPackageJson, versionFromPackageJson] = packageManagerFieldValue.split('@');
202
+ if (versionFromPackageJson &&
203
+ // If it's a URL, it's not a valid range by default, unless users set `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1`.
204
+ // In the unsafe case, there's no way to reliably pare out the version since it could be anything, e.g. http://mydomain.com/bin/yarn.js.
205
+ // See: https://github.com/nodejs/corepack/blob/2b43f26/sources/corepackUtils.ts#L110-L112
206
+ !URL.canParse(versionFromPackageJson) &&
207
+ packageManagerFromPackageJson === requestedPackageManager &&
208
+ versionFromPackageJson) {
209
+ // The range could have a validation hash attached, like "3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa".
210
+ // We just want to parse out the "<major>.<minor>.<patch>". Semver treats "+" as a build, which is not included in the resulting version.
211
+ return (0, semver_1.parse)(versionFromPackageJson)?.version ?? null;
212
+ }
213
+ return null;
214
+ }
202
215
  /**
203
216
  * Checks for a project level npmrc file by crawling up the file tree until
204
217
  * hitting a package.json file, as this is how npm finds them as well.
@@ -349,15 +349,11 @@ function setDefaultsInObject(opts, properties, definitions) {
349
349
  });
350
350
  }
351
351
  function setPropertyDefault(opts, propName, schema, definitions) {
352
+ let defaultValueToSet;
352
353
  if (schema.$ref) {
353
354
  schema = resolveDefinition(schema.$ref, definitions);
354
355
  }
355
- if (schema.type !== 'object' && schema.type !== 'array') {
356
- if (opts[propName] === undefined && schema.default !== undefined) {
357
- opts[propName] = schema.default;
358
- }
359
- }
360
- else if (schema.type === 'array') {
356
+ if (schema.type === 'array') {
361
357
  const items = schema.items || {};
362
358
  if (opts[propName] &&
363
359
  Array.isArray(opts[propName]) &&
@@ -365,19 +361,29 @@ function setPropertyDefault(opts, propName, schema, definitions) {
365
361
  opts[propName].forEach((valueInArray) => setDefaultsInObject(valueInArray, items.properties || {}, definitions));
366
362
  }
367
363
  else if (!opts[propName] && schema.default) {
368
- opts[propName] = schema.default;
364
+ defaultValueToSet = schema.default;
369
365
  }
370
366
  }
371
367
  else {
372
- const wasUndefined = opts[propName] === undefined;
373
- if (wasUndefined) {
374
- // We need an object to set values onto
375
- opts[propName] = {};
376
- }
377
- setDefaultsInObject(opts[propName], schema.properties || {}, definitions);
378
- // If the property was initially undefined but no properties were added, we remove it again instead of having an {}
379
- if (wasUndefined && Object.keys(opts[propName]).length === 0) {
380
- delete opts[propName];
368
+ if (opts[propName] === undefined && schema.default !== undefined) {
369
+ defaultValueToSet = schema.default;
370
+ }
371
+ if (schema.type === 'object') {
372
+ const wasUndefined = opts[propName] === undefined;
373
+ if (!wasUndefined) {
374
+ setDefaultsInObject(opts[propName], schema.properties || {}, definitions);
375
+ }
376
+ }
377
+ }
378
+ if (defaultValueToSet !== undefined) {
379
+ try {
380
+ validateProperty(propName, defaultValueToSet, schema, definitions);
381
+ opts[propName] = defaultValueToSet;
382
+ }
383
+ catch (e) {
384
+ // If the default value is invalid, we don't set it...
385
+ // this should honestly never be needed... but some notable
386
+ // 3rd party schema's are invalid.
381
387
  }
382
388
  }
383
389
  }
@@ -1,32 +0,0 @@
1
- import { NxReleaseChangelogConfiguration } from '../../../config/nx-json';
2
- import { Reference } from './git';
3
- import { ReleaseVersion } from './shared';
4
- export type RepoSlug = `${string}/${string}`;
5
- interface GithubRequestConfig {
6
- repo: string;
7
- hostname: string;
8
- apiBaseUrl: string;
9
- token: string | null;
10
- }
11
- interface GithubRelease {
12
- id?: string;
13
- tag_name: string;
14
- target_commitish?: string;
15
- name?: string;
16
- body?: string;
17
- draft?: boolean;
18
- prerelease?: boolean;
19
- make_latest?: 'legacy' | boolean;
20
- }
21
- export interface GithubRepoData {
22
- hostname: string;
23
- slug: RepoSlug;
24
- apiBaseUrl: string;
25
- }
26
- export declare function getGitHubRepoData(remoteName: string, createReleaseConfig: NxReleaseChangelogConfiguration['createRelease']): GithubRepoData | null;
27
- export declare function createOrUpdateGithubRelease(createReleaseConfig: NxReleaseChangelogConfiguration['createRelease'], releaseVersion: ReleaseVersion, changelogContents: string, latestCommit: string, { dryRun }: {
28
- dryRun: boolean;
29
- }): Promise<void>;
30
- export declare function getGithubReleaseByTag(config: GithubRequestConfig, tag: string): Promise<GithubRelease>;
31
- export declare function formatReferences(references: Reference[], repoData: GithubRepoData): string;
32
- export {};