@ohos-ports/nx 23.2.0-beta.2 → 23.2.0-beta.4

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.
@@ -36,10 +36,12 @@ const postinstallTimeout = setTimeout(() => {
36
36
  }
37
37
  })();
38
38
  function isMainNxPackage() {
39
- const mainNxPath = require.resolve('nx', {
39
+ // @ohos-ports/nx port: resolve the self package under its real name —
40
+ // a bare `nx` specifier would fail when no `node_modules/nx` alias exists.
41
+ const mainNxPath = require.resolve('@ohos-ports/nx', {
40
42
  paths: [workspace_root_1.workspaceRoot],
41
43
  });
42
- const thisNxPath = require.resolve('nx');
44
+ const thisNxPath = require.resolve('@ohos-ports/nx');
43
45
  return mainNxPath === thisNxPath;
44
46
  }
45
47
  process.on('uncaughtException', (e) => {
@@ -1244,7 +1244,7 @@ async function downloadPackageMigrationsFromRegistry(packageName, packageVersion
1244
1244
  const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
1245
1245
  let result;
1246
1246
  try {
1247
- const { tarballPath } = await (0, package_manager_1.packageRegistryPack)(dir, packageName, packageVersion,
1247
+ const { tarballPath } = await (0, package_manager_1.packageRegistryPack)(dir, packageName, packageVersion,
1248
1248
  // packageVersion is exact and already resolved through the workspace
1249
1249
  // package manager's min-release-age policy by the fetcher. In an npm
1250
1250
  // workspace the pack gate IS that policy, so leave it enforcing; for
@@ -1478,7 +1478,7 @@ async function isMigratingToNewMajor(from, to) {
1478
1478
  return (0, semver_1.major)(from) < (0, semver_1.major)(to);
1479
1479
  }
1480
1480
  function readNxVersion(packageJson, root) {
1481
- return ((0, package_json_1.getDependencyVersionFromPackageJson)('nx', root, packageJson) ??
1481
+ return ((0, package_json_1.getDependencyVersionFromPackageJson)('@ohos-ports/nx', root, packageJson) ??
1482
1482
  (0, package_json_1.getDependencyVersionFromPackageJson)('@nx/workspace', root, packageJson) ??
1483
1483
  (0, package_json_1.getDependencyVersionFromPackageJson)('@nrwl/workspace', root, packageJson));
1484
1484
  }
@@ -1890,7 +1890,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
1890
1890
  }
1891
1891
  }
1892
1892
  else if ((0, migration_shape_1.isHybridMigration)(m)) {
1893
- const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1893
+ const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1894
1894
  /* captureGeneratorOutput: */ !!agenticRun, resolvedCollection);
1895
1895
  migrationEmittedNextSteps.push(...nextSteps);
1896
1896
  if (skipAgentic) {
@@ -1949,7 +1949,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
1949
1949
  // Defer commit until validation succeeds; failed validation leaves
1950
1950
  // changes uncommitted in the working tree for the user to review.
1951
1951
  const validationRun = agenticRun && shouldRunValidation ? agenticRun : undefined;
1952
- const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1952
+ const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1953
1953
  /* captureGeneratorOutput: */ !!validationRun, resolvedCollection);
1954
1954
  migrationEmittedNextSteps.push(...nextSteps);
1955
1955
  // Whether a validation step was on the table at all. `skipAgentic`
@@ -2152,7 +2152,7 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, c
2152
2152
  !(await (0, migrate_commits_1.confirmMigrationCommitsOnDefaultBranch)(root, 'running migrations'))) {
2153
2153
  return;
2154
2154
  }
2155
- const { packageJson: orchestratorNxPackageJson } = (0, package_json_1.readModulePackageJson)('nx', (0, installation_directory_1.getNxRequirePaths)(root));
2155
+ const { packageJson: orchestratorNxPackageJson } = (0, package_json_1.readModulePackageJson)('@ohos-ports/nx', (0, installation_directory_1.getNxRequirePaths)(root));
2156
2156
  const { runOrchestratorInit } = require('./run');
2157
2157
  return await runOrchestratorInit({
2158
2158
  root,
@@ -2215,7 +2215,7 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, c
2215
2215
  }
2216
2216
  if (agentic.kind === 'enabled') {
2217
2217
  const { applyAgenticHandoffGitignoreFallback } = require('./agentic/handoff-gitignore');
2218
- const { packageJson: nxPackageJson } = (0, package_json_1.readModulePackageJson)('nx', (0, installation_directory_1.getNxRequirePaths)(root));
2218
+ const { packageJson: nxPackageJson } = (0, package_json_1.readModulePackageJson)('@ohos-ports/nx', (0, installation_directory_1.getNxRequirePaths)(root));
2219
2219
  await applyAgenticHandoffGitignoreFallback({
2220
2220
  migrations,
2221
2221
  installedNxVersion: nxPackageJson.version,
@@ -2651,7 +2651,7 @@ async function runMigration() {
2651
2651
  cliVersionSpec,
2652
2652
  fromEnvOverride: !!process.env.NX_MIGRATE_CLI_VERSION,
2653
2653
  ownNxVersion: versions_1.nxVersion,
2654
- resolveVersion: (spec) =>
2654
+ resolveVersion: (spec) =>
2655
2655
  // A probe must not prompt, write pnpm excludes, or install; a
2656
2656
  // minimum-release-age violation surfaces as a rejection and
2657
2657
  // routes local.
@@ -539,7 +539,7 @@ function buildOutcome(changes, nextSteps, description, root) {
539
539
  // imports both statically.
540
540
  async function prepareAgenticRun(root, migration, agentic, effectiveCreateCommits, commitPrefix) {
541
541
  const { applyAgenticHandoffGitignoreFallback } = require('../agentic/handoff-gitignore');
542
- const { packageJson: nxPackageJson } = (0, package_json_1.readModulePackageJson)('nx', (0, installation_directory_1.getNxRequirePaths)(root));
542
+ const { packageJson: nxPackageJson } = (0, package_json_1.readModulePackageJson)('@ohos-ports/nx', (0, installation_directory_1.getNxRequirePaths)(root));
543
543
  await applyAgenticHandoffGitignoreFallback({
544
544
  migrations: [migration],
545
545
  installedNxVersion: nxPackageJson.version,
@@ -357,7 +357,7 @@ export interface NxReleaseChangelogConfiguration {
357
357
  * If configuring using a custom `ReleaseClient` via the programmatic API, you can either provide a path or directly
358
358
  * provide the implementation class itself.
359
359
  *
360
- * By default, the renderer is set to the DefaultChangelogRenderer implementation from "nx/release/changelog-renderer",
360
+ * By default, the renderer is set to the DefaultChangelogRenderer implementation from "@ohos-ports/nx/release/changelog-renderer",
361
361
  * which nx provides out of the box.
362
362
  */
363
363
  renderer?: string | typeof ChangelogRenderer;
@@ -409,7 +409,7 @@ export interface NxReleaseConventionalCommitsConfiguration {
409
409
  * If not set, this will default to 'true'
410
410
  */
411
411
  useCommitScope?: boolean;
412
- types?: Record<string,
412
+ types?: Record<string,
413
413
  /**
414
414
  * A map of commit types to their configuration.
415
415
  * If a type is set to 'true', then it will be enabled with the default 'semverBump' of 'patch' and will appear in the changelog.
@@ -14,6 +14,15 @@ const transpiler_1 = require("./transpiler");
14
14
  const handle_import_1 = require("../../utils/handle-import");
15
15
  function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
16
16
  try {
17
+ // @ohos-ports/nx port: executor/generator specifiers such as
18
+ // `nx:run-commands` resolve the plugin package by the literal name `nx`.
19
+ // When this CLI is installed as `@ohos-ports/nx` without a
20
+ // `node_modules/nx` alias, map the self-package specifier to the real
21
+ // package name so Node's package self-reference (via "exports")
22
+ // resolves it to this package itself.
23
+ if (pluginName === 'nx') {
24
+ pluginName = '@ohos-ports/nx';
25
+ }
17
26
  const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
18
27
  return {
19
28
  json: result.packageJson,
@@ -11,7 +11,14 @@ function isIsolationEnabled() {
11
11
  // Explicitly disabled
12
12
  process.env.NX_ISOLATE_PLUGINS === 'false' ||
13
13
  // Isolation is disabled on WASM builds currently.
14
- native_1.IS_WASM) {
14
+ native_1.IS_WASM ||
15
+ // HarmonyOS (openharmony): the hmfs file system enforces mode 2771 on
16
+ // all directories (chmod 0700 cannot stick), so the 0700 socket dir
17
+ // required by plugin isolation cannot be created. Default to nx's
18
+ // in-process plugin loading unless NX_ISOLATE_PLUGINS is explicitly
19
+ // set (explicit values are respected by the branches above).
20
+ (process.platform === 'openharmony' &&
21
+ process.env.NX_ISOLATE_PLUGINS === undefined)) {
15
22
  return false;
16
23
  }
17
24
  // Default value
@@ -41,7 +41,9 @@ function getInstalledVersion(packageName) {
41
41
  * `nx` can be located.
42
42
  */
43
43
  function getInstalledNxVersion() {
44
- return getInstalledVersion('nx');
44
+ // @ohos-ports/nx port: the "installed nx" is this package itself; resolve
45
+ // under the real package name (no `node_modules/nx` alias is guaranteed).
46
+ return getInstalledVersion('@ohos-ports/nx');
45
47
  }
46
48
  /**
47
49
  * Resolve the workspace's installed `@nrwl/workspace` version (legacy-era
@@ -158,6 +158,13 @@ function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceR
158
158
  * @returns package json contents and path
159
159
  */
160
160
  function readModulePackageJsonWithoutFallbacks(moduleSpecifier, requirePaths = (0, installation_directory_1.getNxRequirePaths)()) {
161
+ // @ohos-ports/nx port: a bare `nx` specifier here refers to the nx package
162
+ // itself. When installed as `@ohos-ports/nx` without a `node_modules/nx`
163
+ // alias, map it to the real package name so Node's package self-reference
164
+ // (via "exports") resolves it to this package itself.
165
+ if (moduleSpecifier === 'nx') {
166
+ moduleSpecifier = '@ohos-ports/nx';
167
+ }
161
168
  const packageJsonPath = require.resolve(`${moduleSpecifier}/package.json`, {
162
169
  paths: requirePaths,
163
170
  });
@@ -182,6 +189,10 @@ function readModulePackageJsonWithoutFallbacks(moduleSpecifier, requirePaths = (
182
189
  * @returns package json contents and path
183
190
  */
184
191
  function readModulePackageJson(moduleSpecifier, requirePaths = (0, installation_directory_1.getNxRequirePaths)()) {
192
+ // @ohos-ports/nx port: see readModulePackageJsonWithoutFallbacks above.
193
+ if (moduleSpecifier === 'nx') {
194
+ moduleSpecifier = '@ohos-ports/nx';
195
+ }
185
196
  let packageJsonPath;
186
197
  let packageJson;
187
198
  try {
@@ -31,7 +31,10 @@ function workspaceRootInner(dir, candidateRoot) {
31
31
  // e.g. packages/my-lib/package.json contains @nx/devkit, which references Nx and is
32
32
  // thus located in //packages/my-lib/node_modules/nx/package.json
33
33
  }
34
- else if ((0, fileutils_1.fileExists)(path.join(dir, 'node_modules', 'nx', 'package.json'))) {
34
+ else if ((0, fileutils_1.fileExists)(path.join(dir, 'node_modules', 'nx', 'package.json')) ||
35
+ // @ohos-ports/nx port: the workspace's nx dependency may be installed
36
+ // under the ported package name without a `node_modules/nx` alias.
37
+ (0, fileutils_1.fileExists)(path.join(dir, 'node_modules', '@ohos-ports', 'nx', 'package.json'))) {
35
38
  return workspaceRootInner(path.dirname(dir), dir);
36
39
  }
37
40
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-ports/nx",
3
- "version": "23.2.0-beta.2",
3
+ "version": "23.2.0-beta.4",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
@@ -173,7 +173,7 @@
173
173
  "yargs-parser": "21.1.1"
174
174
  },
175
175
  "peerDependencies": {
176
- "@swc-node/register": "^1.11.1",
176
+ "@ohos-ports/swc-node-register": "^1.12.1-beta.0",
177
177
  "@ohos-ports/swc-core": "^1.15.43-beta.1"
178
178
  },
179
179
  "peerDependenciesMeta": {