@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.
- package/README.md +8 -9
- package/{LICENSE → dist/LICENSE} +1 -1
- package/dist/babel.d.ts +1 -0
- package/{babel.js → dist/babel.js} +2 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +11 -0
- package/dist/src/executors/file-server/compat.js +6 -0
- package/{src → dist/src}/executors/file-server/file-server.impl.d.ts +1 -1
- package/{src → dist/src}/executors/file-server/file-server.impl.js +33 -21
- package/{src → dist/src}/executors/file-server/schema.json +9 -1
- package/{src → dist/src}/generators/application/application.d.ts +1 -1
- package/{src → dist/src}/generators/application/application.js +223 -131
- package/{src → dist/src}/generators/application/files/app-vite/index.html__tmpl__ +1 -1
- package/{src → dist/src}/generators/application/files/app-vite/tsconfig.app.json +1 -1
- package/{src → dist/src}/generators/application/files/app-vite/tsconfig.json__tmpl__ +1 -1
- package/{src → dist/src}/generators/application/files/app-webpack/src/index.html +1 -1
- package/{src → dist/src}/generators/application/files/app-webpack/tsconfig.app.json +1 -1
- package/{src → dist/src}/generators/application/files/app-webpack/webpack.config.js__tmpl__ +4 -2
- package/{src → dist/src}/generators/application/schema.d.ts +11 -7
- package/{src → dist/src}/generators/application/schema.json +37 -30
- package/{src → dist/src}/generators/init/init.d.ts +1 -1
- package/{src → dist/src}/generators/init/init.js +1 -1
- package/{src → dist/src}/generators/static-serve/schema.json +4 -0
- package/{src → dist/src}/generators/static-serve/static-serve-configuration.d.ts +2 -1
- package/{src → dist/src}/generators/static-serve/static-serve-configuration.js +3 -1
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +197 -0
- package/dist/src/plugins/webpack-nx-build-coordination-plugin.d.ts +1 -0
- package/dist/src/plugins/webpack-nx-build-coordination-plugin.js +5 -0
- package/dist/src/utils/fs.d.ts +1 -0
- package/dist/src/utils/fs.js +7 -0
- package/{src → dist/src}/utils/has-vite-plugin.d.ts +1 -1
- package/{src → dist/src}/utils/has-vite-plugin.js +1 -1
- package/{src → dist/src}/utils/has-webpack-plugin.d.ts +1 -1
- package/{src → dist/src}/utils/has-webpack-plugin.js +1 -1
- package/dist/src/utils/normalize.d.ts +1 -0
- package/dist/src/utils/normalize.js +6 -0
- package/{src → dist/src}/utils/versions.d.ts +1 -1
- package/{src → dist/src}/utils/versions.js +3 -2
- package/{src → dist/src}/utils/wait-for-port-open.js +3 -2
- package/dist/typings/style.d.ts +5 -0
- package/executors.json +4 -4
- package/generators.json +6 -6
- package/migrations.json +5 -22
- package/package.json +93 -16
- package/scripts/consumer-compat.js +134 -0
- package/babel.d.ts +0 -1
- package/src/executors/file-server/compat.js +0 -5
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.d.ts +0 -2
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.js +0 -34
- package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +0 -1
- package/src/plugins/webpack-nx-build-coordination-plugin.js +0 -5
- package/src/utils/fs.d.ts +0 -1
- package/src/utils/fs.js +0 -4
- package/src/utils/normalize.d.ts +0 -1
- package/src/utils/normalize.js +0 -4
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{src → dist/src}/executors/file-server/compat.d.ts +0 -0
- /package/{src → dist/src}/executors/file-server/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/.babelrc__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/public/favicon.ico +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.__style__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.spec.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/app/app.element.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/assets/.gitkeep +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/main.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-vite/src/styles.__style__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.__style__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.spec.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/app/app.element.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/assets/.gitkeep +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/favicon.ico +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/main.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/src/styles.__style__ +0 -0
- /package/{src → dist/src}/generators/application/files/app-webpack/tsconfig.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/init/schema.json +0 -0
- /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
|
|
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
|
-
[]()
|
|
10
|
+
[](<>)
|
|
11
|
+
[](https://www.npmjs.com/package/nx)
|
|
12
|
+
[](<>)
|
|
14
13
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
-
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
14
|
[](https://go.nx.dev/community)
|
|
15
|
+
[](https://nx.dev/nx-cloud)
|
|
17
16
|
|
|
18
17
|
</div>
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
<hr>
|
|
22
21
|
|
|
23
|
-
# Nx: Smart Monorepos · Fast
|
|
22
|
+
# Nx: Smart Monorepos · Fast Builds
|
|
24
23
|
|
|
25
|
-
|
|
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
|
|
66
|
+
width="100%" alt="Nx - Smart Monorepos · Fast Builds"></a></p>
|
|
68
67
|
|
package/{LICENSE → dist/LICENSE}
RENAMED
package/dist/babel.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/internal.js
ADDED
|
@@ -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,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
|
|
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
|
|
11
|
-
const
|
|
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,
|
|
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
|
|
96
|
+
return internal_1.daemonClient.registerFileWatcher({
|
|
98
97
|
watchProjects: project ? [project] : 'all',
|
|
99
98
|
includeGlobalWorkspaceFiles: true,
|
|
100
|
-
|
|
99
|
+
includeDependencies: true,
|
|
101
100
|
}, async (error, val) => {
|
|
102
|
-
if (error === '
|
|
103
|
-
|
|
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)(
|
|
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 (!
|
|
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 (
|
|
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
|
|
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,
|
|
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
|
-
"
|
|
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
|
|
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>;
|