@ohos-ports/nx-web 19.8.4-beta.1 → 23.3.0-beta.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 (81) hide show
  1. package/README.md +8 -9
  2. package/{LICENSE → dist/LICENSE} +1 -1
  3. package/dist/babel.d.ts +1 -0
  4. package/{babel.js → dist/babel.js} +2 -0
  5. package/dist/internal.d.ts +2 -0
  6. package/dist/internal.js +11 -0
  7. package/dist/src/executors/file-server/compat.js +6 -0
  8. package/{src → dist/src}/executors/file-server/file-server.impl.d.ts +1 -1
  9. package/{src → dist/src}/executors/file-server/file-server.impl.js +33 -21
  10. package/{src → dist/src}/executors/file-server/schema.json +9 -1
  11. package/{src → dist/src}/generators/application/application.d.ts +1 -1
  12. package/{src → dist/src}/generators/application/application.js +223 -131
  13. package/{src → dist/src}/generators/application/files/app-vite/index.html__tmpl__ +1 -1
  14. package/{src → dist/src}/generators/application/files/app-vite/tsconfig.app.json +1 -1
  15. package/{src → dist/src}/generators/application/files/app-vite/tsconfig.json__tmpl__ +1 -1
  16. package/{src → dist/src}/generators/application/files/app-webpack/src/index.html +1 -1
  17. package/{src → dist/src}/generators/application/files/app-webpack/tsconfig.app.json +1 -1
  18. package/{src → dist/src}/generators/application/files/app-webpack/webpack.config.js__tmpl__ +4 -2
  19. package/{src → dist/src}/generators/application/schema.d.ts +11 -7
  20. package/{src → dist/src}/generators/application/schema.json +37 -30
  21. package/{src → dist/src}/generators/init/init.d.ts +1 -1
  22. package/{src → dist/src}/generators/init/init.js +1 -1
  23. package/{src → dist/src}/generators/static-serve/schema.json +4 -0
  24. package/{src → dist/src}/generators/static-serve/static-serve-configuration.d.ts +2 -1
  25. package/{src → dist/src}/generators/static-serve/static-serve-configuration.js +3 -1
  26. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
  27. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +197 -0
  28. package/dist/src/plugins/webpack-nx-build-coordination-plugin.d.ts +1 -0
  29. package/dist/src/plugins/webpack-nx-build-coordination-plugin.js +5 -0
  30. package/dist/src/utils/fs.d.ts +1 -0
  31. package/dist/src/utils/fs.js +7 -0
  32. package/{src → dist/src}/utils/has-vite-plugin.d.ts +1 -1
  33. package/{src → dist/src}/utils/has-vite-plugin.js +1 -1
  34. package/{src → dist/src}/utils/has-webpack-plugin.d.ts +1 -1
  35. package/{src → dist/src}/utils/has-webpack-plugin.js +1 -1
  36. package/dist/src/utils/normalize.d.ts +1 -0
  37. package/dist/src/utils/normalize.js +6 -0
  38. package/{src → dist/src}/utils/versions.d.ts +1 -1
  39. package/{src → dist/src}/utils/versions.js +3 -2
  40. package/{src → dist/src}/utils/wait-for-port-open.js +3 -2
  41. package/dist/typings/style.d.ts +5 -0
  42. package/executors.json +4 -4
  43. package/generators.json +6 -6
  44. package/migrations.json +5 -22
  45. package/package.json +93 -16
  46. package/scripts/consumer-compat.js +134 -0
  47. package/babel.d.ts +0 -1
  48. package/src/executors/file-server/compat.js +0 -5
  49. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  50. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  51. package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.d.ts +0 -2
  52. package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.js +0 -34
  53. package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +0 -1
  54. package/src/plugins/webpack-nx-build-coordination-plugin.js +0 -5
  55. package/src/utils/fs.d.ts +0 -1
  56. package/src/utils/fs.js +0 -4
  57. package/src/utils/normalize.d.ts +0 -1
  58. package/src/utils/normalize.js +0 -4
  59. /package/{index.d.ts → dist/index.d.ts} +0 -0
  60. /package/{index.js → dist/index.js} +0 -0
  61. /package/{src → dist/src}/executors/file-server/compat.d.ts +0 -0
  62. /package/{src → dist/src}/executors/file-server/schema.d.ts +0 -0
  63. /package/{src → dist/src}/generators/application/files/app-vite/.babelrc__tmpl__ +0 -0
  64. /package/{src → dist/src}/generators/application/files/app-vite/public/favicon.ico +0 -0
  65. /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.__style__ +0 -0
  66. /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.spec.ts__tmpl__ +0 -0
  67. /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.ts__tmpl__ +0 -0
  68. /package/{src → dist/src}/generators/application/files/app-vite/src/assets/.gitkeep +0 -0
  69. /package/{src → dist/src}/generators/application/files/app-vite/src/main.ts__tmpl__ +0 -0
  70. /package/{src → dist/src}/generators/application/files/app-vite/src/styles.__style__ +0 -0
  71. /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.__style__ +0 -0
  72. /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.spec.ts__tmpl__ +0 -0
  73. /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.ts__tmpl__ +0 -0
  74. /package/{src → dist/src}/generators/application/files/app-webpack/src/assets/.gitkeep +0 -0
  75. /package/{src → dist/src}/generators/application/files/app-webpack/src/favicon.ico +0 -0
  76. /package/{src → dist/src}/generators/application/files/app-webpack/src/main.ts__tmpl__ +0 -0
  77. /package/{src → dist/src}/generators/application/files/app-webpack/src/styles.__style__ +0 -0
  78. /package/{src → dist/src}/generators/application/files/app-webpack/tsconfig.json +0 -0
  79. /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
  80. /package/{src → dist/src}/generators/init/schema.json +0 -0
  81. /package/{src → dist/src}/utils/wait-for-port-open.d.ts +0 -0
package/README.md CHANGED
@@ -1,28 +1,27 @@
1
1
  <p style="text-align: center;">
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
- <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
4
+ <img alt="Nx - Smart Monorepos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
5
  </picture>
6
6
  </p>
7
7
 
8
8
  <div style="text-align: center;">
9
9
 
10
- [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
- [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
- [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
- [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
10
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)](<>)
11
+ [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
12
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](<>)
14
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
- [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
+ [![Hours saved](https://img.shields.io/endpoint?url=https%3A%2F%2Fstaging.nx.app%2Fnx-cloud%2Fbadge%2F62d013ea0852fe0a2df74438%2Fhours-saved.json)](https://nx.dev/nx-cloud)
17
16
 
18
17
  </div>
19
18
 
20
19
 
21
20
  <hr>
22
21
 
23
- # Nx: Smart Monorepos · Fast CI
22
+ # Nx: Smart Monorepos · Fast Builds
24
23
 
25
- Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
24
+ Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
26
25
 
27
26
  This package is a [Web plugin for Nx](https://nx.dev/nx-api/web).
28
27
 
@@ -64,5 +63,5 @@ npx nx@latest init
64
63
  - [Blog Posts About Nx](https://nx.dev/blog)
65
64
 
66
65
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
67
- width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
66
+ width="100%" alt="Nx - Smart Monorepos · Fast Builds"></a></p>
68
67
 
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2024 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2026 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const nxJsBabelPreset = require('@nx/js/babel');
2
4
  /** @deprecated Use `@nx/js/babel`. */
3
5
  module.exports = function (api, options = {}) {
@@ -0,0 +1,2 @@
1
+ export { waitForPortOpen } from './src/utils/wait-for-port-open';
2
+ export { default as fileServerExecutor } from './src/executors/file-server/file-server.impl';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileServerExecutor = exports.waitForPortOpen = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Curated internal API surface for other first-party Nx plugins (e.g. @nx/react,
6
+ // @nx/angular, @nx/rspack, @nx/next, @nx/remix, @nx/module-federation). Prefer
7
+ // this over deep `@nx/web/src/*` imports — those are not part of the public API.
8
+ var wait_for_port_open_1 = require("./src/utils/wait-for-port-open");
9
+ Object.defineProperty(exports, "waitForPortOpen", { enumerable: true, get: function () { return wait_for_port_open_1.waitForPortOpen; } });
10
+ var file_server_impl_1 = require("./src/executors/file-server/file-server.impl");
11
+ Object.defineProperty(exports, "fileServerExecutor", { enumerable: true, get: function () { return tslib_1.__importDefault(file_server_impl_1).default; } });
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@ohos-ports/nx-devkit");
5
+ const file_server_impl_1 = tslib_1.__importDefault(require("./file-server.impl"));
6
+ exports.default = (0, devkit_1.convertNxExecutor)(file_server_impl_1.default);
@@ -1,4 +1,4 @@
1
- import { ExecutorContext } from '@nx/devkit';
1
+ import { ExecutorContext } from '@ohos-ports/nx-devkit';
2
2
  import { Schema } from './schema';
3
3
  export default function fileServerExecutor(options: Schema, context: ExecutorContext): AsyncGenerator<{
4
4
  success: boolean;
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = fileServerExecutor;
4
+ const tslib_1 = require("tslib");
5
+ const internal_1 = require("@ohos-ports/nx-devkit/internal");
4
6
  const child_process_1 = require("child_process");
5
- const pc = require("picocolors");
6
- const devkit_1 = require("@nx/devkit");
7
+ const pc = tslib_1.__importStar(require("picocolors"));
8
+ const devkit_1 = require("@ohos-ports/nx-devkit");
7
9
  const fs_1 = require("fs");
8
- const os_1 = require("os");
9
10
  const path_1 = require("path");
10
- const package_json_1 = require("nx/src/utils/package-json");
11
- const detectPort = require("detect-port");
12
- const client_1 = require("nx/src/daemon/client/client");
13
- const utils_1 = require("nx/src/tasks-runner/utils");
14
- // platform specific command name
15
- const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
11
+ const internal_2 = require("@nx/js/internal");
12
+ const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
16
13
  function getHttpServerArgs(options) {
17
14
  const { buildTarget, parallel, host, proxyUrl, ssl, sslCert, sslKey, proxyOptions, watch, spa, cacheSeconds, ...rest } = options;
18
15
  const args = [`-c${options.cacheSeconds}`];
@@ -78,11 +75,13 @@ function getBuildTargetOutputPath(options, context) {
78
75
  const project = context.projectGraph.nodes[context.projectName];
79
76
  const buildTarget = project.data.targets[target.target];
80
77
  outputPath = buildTarget.outputs?.[0];
81
- if (outputPath)
82
- outputPath = (0, utils_1.interpolate)(outputPath, {
78
+ if (outputPath) {
79
+ outputPath = (0, internal_1.interpolate)(outputPath, {
83
80
  projectName: project.data.name,
84
81
  projectRoot: project.data.root,
85
82
  });
83
+ outputPath = (0, internal_2.stripGlobToBaseDir)(outputPath);
84
+ }
86
85
  }
87
86
  }
88
87
  catch (e) {
@@ -94,13 +93,21 @@ function getBuildTargetOutputPath(options, context) {
94
93
  return outputPath;
95
94
  }
96
95
  function createFileWatcher(project, changeHandler) {
97
- return client_1.daemonClient.registerFileWatcher({
96
+ return internal_1.daemonClient.registerFileWatcher({
98
97
  watchProjects: project ? [project] : 'all',
99
98
  includeGlobalWorkspaceFiles: true,
100
- includeDependentProjects: true,
99
+ includeDependencies: true,
101
100
  }, async (error, val) => {
102
- if (error === 'closed') {
103
- throw new Error('Watch error: Daemon closed the connection');
101
+ if (error === 'reconnecting') {
102
+ // Silent - daemon restarts automatically on lockfile changes
103
+ return;
104
+ }
105
+ else if (error === 'reconnected') {
106
+ // Silent - reconnection succeeded
107
+ return;
108
+ }
109
+ else if (error === 'closed') {
110
+ throw new Error('Failed to reconnect to daemon after multiple attempts');
104
111
  }
105
112
  else if (error) {
106
113
  throw new Error(`Watch error: ${error?.message ?? 'Unknown'}`);
@@ -120,6 +127,9 @@ async function* fileServerExecutor(options, context) {
120
127
  let running = false;
121
128
  let disposeWatch;
122
129
  if (options.buildTarget) {
130
+ // Run the build target through the workspace package manager so workspaces
131
+ // that pin a non-npm manager (e.g. devEngines.packageManager) don't fail.
132
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
123
133
  const run = () => {
124
134
  if (!running) {
125
135
  running = true;
@@ -131,7 +141,7 @@ async function* fileServerExecutor(options, context) {
131
141
  process.env.NX_SERVE_STATIC_BUILD_RUNNING = 'true';
132
142
  try {
133
143
  const args = getBuildTargetCommand(options, context);
134
- (0, child_process_1.execFileSync)(pmCmd, args, {
144
+ (0, child_process_1.execFileSync)(pmc.exec, args, {
135
145
  stdio: [0, 1, 2],
136
146
  shell: true,
137
147
  windowsHide: true,
@@ -146,18 +156,18 @@ async function* fileServerExecutor(options, context) {
146
156
  }
147
157
  }
148
158
  };
149
- if (!client_1.daemonClient.enabled() && options.watch) {
159
+ if (!internal_1.daemonClient.enabled() && options.watch) {
150
160
  devkit_1.output.warn({
151
161
  title: 'Nx Daemon is not enabled. Static server is not watching for changes.',
152
162
  });
153
163
  }
154
- if (client_1.daemonClient.enabled() && options.watch) {
164
+ if (internal_1.daemonClient.enabled() && options.watch) {
155
165
  disposeWatch = await createFileWatcher(context.projectName, run);
156
166
  }
157
167
  // perform initial run
158
168
  run();
159
169
  }
160
- const port = await detectPort(options.port || 8080);
170
+ const port = await (0, detect_port_1.default)(options.port || 8080);
161
171
  const outputPath = getBuildTargetOutputPath(options, context);
162
172
  if (options.spa) {
163
173
  const src = (0, path_1.join)(outputPath, 'index.html');
@@ -169,7 +179,7 @@ async function* fileServerExecutor(options, context) {
169
179
  options.proxyUrl ??= `http${options.ssl ? 's' : ''}://localhost:${port}?`;
170
180
  }
171
181
  const args = getHttpServerArgs(options);
172
- const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
182
+ const { path: pathToHttpServerPkgJson, packageJson } = (0, internal_1.readModulePackageJson)('http-server', module.paths);
173
183
  const pathToHttpServerBin = packageJson.bin['http-server'];
174
184
  const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
175
185
  // detect port as close to when used to prevent port being used by another process
@@ -207,7 +217,9 @@ async function* fileServerExecutor(options, context) {
207
217
  baseUrl: `${options.ssl ? 'https' : 'http'}://${options.host}:${port}`,
208
218
  };
209
219
  return new Promise((res) => {
210
- serve.on('exit', (code) => {
220
+ serve.on('exit', (code, signal) => {
221
+ if (code === null)
222
+ code = (0, internal_1.signalToCode)(signal);
211
223
  if (code == 0) {
212
224
  res({ success: true });
213
225
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "version": 2,
3
+ "continuous": true,
3
4
  "outputCapture": "direct-nodejs",
4
5
  "title": "File Server",
5
6
  "description": "Serve a web application from a folder. This executor is a wrapper around the [http-server](https://www.npmjs.com/package/http-server) package.",
@@ -74,7 +75,14 @@
74
75
  "description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath"
75
76
  },
76
77
  "cors": {
77
- "type": "boolean",
78
+ "oneOf": [
79
+ {
80
+ "type": "boolean"
81
+ },
82
+ {
83
+ "type": "string"
84
+ }
85
+ ],
78
86
  "description": "Enable CORS",
79
87
  "default": true
80
88
  },
@@ -1,4 +1,4 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@ohos-ports/nx-devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function applicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
4
  export declare function applicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;