@toolsplus/nx-forge 6.0.0 → 6.0.1-test-fix-tunnel-executor.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/package.json +1 -1
- package/src/executors/tunnel/executor.d.ts +5 -4
- package/src/executors/tunnel/executor.js +31 -25
- package/src/executors/tunnel/executor.js.map +1 -1
- package/src/executors/tunnel/lib/extract-custom-ui-projects.js +2 -3
- package/src/executors/tunnel/lib/extract-custom-ui-projects.js.map +1 -1
- package/src/executors/tunnel/lib/run-tunnel.d.ts +17 -1
- package/src/executors/tunnel/lib/run-tunnel.js +69 -10
- package/src/executors/tunnel/lib/run-tunnel.js.map +1 -1
- package/src/executors/tunnel/lib/start-custom-uis.d.ts +7 -0
- package/src/executors/tunnel/lib/start-custom-uis.js +15 -0
- package/src/executors/tunnel/lib/start-custom-uis.js.map +1 -0
- package/src/executors/tunnel/schema.d.ts +1 -0
- package/src/executors/tunnel/schema.json +6 -0
- package/src/generators/application/files/webpack.config.js__tmpl__ +5 -0
- package/src/graph/create-nodes.js +2 -2
- package/src/graph/create-nodes.js.map +1 -1
- package/src/shared/targets/get-tunnel-config.d.ts +6 -0
- package/src/shared/targets/{get-serve-config.js → get-tunnel-config.js} +3 -3
- package/src/shared/targets/get-tunnel-config.js.map +1 -0
- package/src/shared/targets/get-serve-config.d.ts +0 -6
- package/src/shared/targets/get-serve-config.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { TunnelExecutorOptions } from './schema';
|
|
3
3
|
/**
|
|
4
|
-
* Forge tunnel executor that serves
|
|
5
|
-
*
|
|
4
|
+
* Forge tunnel executor that serves dependent Custom UI projects on the tunnel
|
|
5
|
+
* port configured in the manifest.yml.
|
|
6
6
|
*
|
|
7
|
-
* Additionally, this will start a build process for the Forge app in watch mode
|
|
8
|
-
*
|
|
7
|
+
* Additionally, this will start a build process for the Forge app in watch mode,
|
|
8
|
+
* call the package executor once to copy Forge app assets to the output directory
|
|
9
|
+
* and launch the `forge tunnel` process in the configured output directory.
|
|
9
10
|
*
|
|
10
11
|
* @see https://github.com/nrwl/nx/issues/3748#issuecomment-990980640
|
|
11
12
|
* @see https://gist.github.com/chrisui/a3cdf050bf18eccd499fba29b609b90a
|
|
@@ -4,14 +4,16 @@ exports.default = runTunnelExecutor;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
|
-
const run_tunnel_1 = tslib_1.
|
|
7
|
+
const run_tunnel_1 = tslib_1.__importStar(require("./lib/run-tunnel"));
|
|
8
8
|
const extract_custom_ui_projects_1 = require("./lib/extract-custom-ui-projects");
|
|
9
|
+
const start_custom_uis_1 = require("./lib/start-custom-uis");
|
|
9
10
|
/**
|
|
10
|
-
* Forge tunnel executor that serves
|
|
11
|
-
*
|
|
11
|
+
* Forge tunnel executor that serves dependent Custom UI projects on the tunnel
|
|
12
|
+
* port configured in the manifest.yml.
|
|
12
13
|
*
|
|
13
|
-
* Additionally, this will start a build process for the Forge app in watch mode
|
|
14
|
-
*
|
|
14
|
+
* Additionally, this will start a build process for the Forge app in watch mode,
|
|
15
|
+
* call the package executor once to copy Forge app assets to the output directory
|
|
16
|
+
* and launch the `forge tunnel` process in the configured output directory.
|
|
15
17
|
*
|
|
16
18
|
* @see https://github.com/nrwl/nx/issues/3748#issuecomment-990980640
|
|
17
19
|
* @see https://gist.github.com/chrisui/a3cdf050bf18eccd499fba29b609b90a
|
|
@@ -20,45 +22,49 @@ const extract_custom_ui_projects_1 = require("./lib/extract-custom-ui-projects")
|
|
|
20
22
|
function runTunnelExecutor(options, context) {
|
|
21
23
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
24
|
var _a, e_1, _b, _c;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
var _d;
|
|
26
|
+
const customUIProjectConfigs = yield (0, extract_custom_ui_projects_1.getCustomUiProjects)(context);
|
|
27
|
+
const customUIIters = yield (0, start_custom_uis_1.startCustomUIs)(customUIProjectConfigs, context);
|
|
28
|
+
const forgeAppBuildIter = yield (0, devkit_1.runExecutor)({ project: context.projectName, target: 'build' }, { watch: true }, context);
|
|
29
|
+
yield (0, devkit_1.runExecutor)({ project: context.projectName, target: 'package' }, {}, context);
|
|
30
|
+
try {
|
|
31
|
+
const preTunnelTimeout = (_d = options.preTunnelTimeout) !== null && _d !== void 0 ? _d : 5000;
|
|
32
|
+
yield (0, run_tunnel_1.isTunnelPreparationComplete)(options.outputPath, preTunnelTimeout);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
devkit_1.logger.info(err.message);
|
|
36
|
+
return { success: false };
|
|
32
37
|
}
|
|
33
|
-
const runForgeAppBuild = yield (0, devkit_1.runExecutor)({ project: context.projectName, target: 'build' }, { watch: true }, context);
|
|
34
38
|
// execute the tunnel target on the focused project
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
// we combine (interleave) all executor iterators here
|
|
38
|
-
const combined = (0, async_iterable_1.combineAsyncIterables)(runAllCustomUiServe, runForgeAppBuild, runForgeTunnel);
|
|
39
|
+
const forgeTunnelIter = promiseToIterator((0, run_tunnel_1.default)(Object.assign(Object.assign({}, options), { customUIProjectConfigs }), context));
|
|
40
|
+
const combined = (0, async_iterable_1.combineAsyncIterables)(forgeAppBuildIter, ...customUIIters, forgeTunnelIter);
|
|
39
41
|
try {
|
|
40
42
|
try {
|
|
41
|
-
for (var
|
|
43
|
+
for (var _e = true, combined_1 = tslib_1.__asyncValues(combined), combined_1_1; combined_1_1 = yield combined_1.next(), _a = combined_1_1.done, !_a; _e = true) {
|
|
42
44
|
_c = combined_1_1.value;
|
|
43
|
-
|
|
45
|
+
_e = false;
|
|
44
46
|
const output = _c;
|
|
45
47
|
if (!output.success)
|
|
46
|
-
|
|
48
|
+
throw new Error(`A started process failed: ${JSON.stringify(output)}`);
|
|
49
|
+
if ((output === null || output === void 0 ? void 0 : output.id) === 'tunnel') {
|
|
50
|
+
devkit_1.logger.info('Tunnel process has been terminated.');
|
|
51
|
+
const { value } = yield combined.return({ success: true });
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
50
57
|
finally {
|
|
51
58
|
try {
|
|
52
|
-
if (!
|
|
59
|
+
if (!_e && !_a && (_b = combined_1.return)) yield _b.call(combined_1);
|
|
53
60
|
}
|
|
54
61
|
finally { if (e_1) throw e_1.error; }
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
catch (err) {
|
|
58
65
|
devkit_1.logger.error(`Failed to tunnel Forge app: ${err}`);
|
|
59
|
-
|
|
66
|
+
return yield combined.return({ success: false });
|
|
60
67
|
}
|
|
61
|
-
return { success: true };
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
70
|
function promiseToIterator(v) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/executors/tunnel/executor.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/executors/tunnel/executor.ts"],"names":[],"mappings":";;AAmBA,oCAmDC;;AAtED,uCAAkE;AAClE,wEAA4E;AAE5E,uEAA0E;AAC1E,iFAAuE;AACvE,6DAAwD;AAExD;;;;;;;;;;;GAWG;AACH,SAA8B,iBAAiB,CAC7C,OAA8B,EAC9B,OAAwB;;;;QAExB,MAAM,sBAAsB,GAAG,MAAM,IAAA,gDAAmB,EAAC,OAAO,CAAC,CAAC;QAElE,MAAM,aAAa,GAAG,MAAM,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N,MAAM,CAAE,EAAE,MAAK,QAAQ,EAAE,CAAC;wBAC5B,eAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;wBACnD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC3D,OAAO,KAAK,CAAC;oBACf,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,eAAM,CAAC,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;YACnD,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CAAA;AAED,SAAgB,iBAAiB,CAG/B,CAAa;;QACb,4BAAM,sBAAM,CAAC,CAAA,CAAA,CAAC;IAChB,CAAC;CAAA"}
|
|
@@ -12,7 +12,7 @@ const manifest_yml_1 = require("../../../utils/forge/manifest-yml");
|
|
|
12
12
|
*/
|
|
13
13
|
function getCustomUiProjects(context) {
|
|
14
14
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const projects = yield
|
|
15
|
+
const projects = yield extractVerifiedCustomUIProjects(context);
|
|
16
16
|
return projects.map((p) => ({
|
|
17
17
|
projectName: p.path,
|
|
18
18
|
port: p.tunnel.port,
|
|
@@ -26,13 +26,12 @@ function getCustomUiProjects(context) {
|
|
|
26
26
|
*
|
|
27
27
|
* - the Nx workspace has a project configured for each Custom UI project
|
|
28
28
|
* - each Custom UI project has a 'serve' target
|
|
29
|
-
* - each Custom UI project is listed as an implicit dependency of the Forge app
|
|
30
29
|
* - each Custom UI resource has a configured tunnel port in the Forge app's manifest.yml
|
|
31
30
|
*
|
|
32
31
|
* @param context Executor context for this call
|
|
33
32
|
* @returns All configured and verified Custom UI resources
|
|
34
33
|
*/
|
|
35
|
-
function
|
|
34
|
+
function extractVerifiedCustomUIProjects(context) {
|
|
36
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
37
|
const manifestPath = (0, devkit_1.joinPathFragments)(context.root, context.projectsConfigurations.projects[context.projectName].root, 'manifest.yml');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-custom-ui-projects.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/tunnel/lib/extract-custom-ui-projects.ts"],"names":[],"mappings":";;AAaA,kDAQC;;AArBD,uCAAgE;AAGhE,oEAAoE;AAIpE;;;;;GAKG;AACH,SAAsB,mBAAmB,CACvC,OAAwB;;QAExB,MAAM,QAAQ,GAAG,MAAM,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,WAAW,EAAE,CAAC,CAAC,IAAI;YACnB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;SACpB,CAAC,CAAC,CAAC;IACN,CAAC;CAAA;AAED
|
|
1
|
+
{"version":3,"file":"extract-custom-ui-projects.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/tunnel/lib/extract-custom-ui-projects.ts"],"names":[],"mappings":";;AAaA,kDAQC;;AArBD,uCAAgE;AAGhE,oEAAoE;AAIpE;;;;;GAKG;AACH,SAAsB,mBAAmB,CACvC,OAAwB;;QAExB,MAAM,QAAQ,GAAG,MAAM,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,WAAW,EAAE,CAAC,CAAC,IAAI;YACnB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;SACpB,CAAC,CAAC,CAAC;IACN,CAAC;CAAA;AAED;;;;;;;;;;;GAWG;AACH,SAAe,+BAA+B,CAC5C,OAAwB;;;QAExB,MAA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
2
|
import { TunnelExecutorOptions } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the tunnel executor is ready to run the Forge tunnel process.
|
|
5
|
+
*
|
|
6
|
+
* Checks if:
|
|
7
|
+
* - the manifest.yml exists in the output path
|
|
8
|
+
* - the `src` directory in the output path is non-empty
|
|
9
|
+
*
|
|
10
|
+
* This will perform these checks repeatedly with exponential backoff until,
|
|
11
|
+
* either the function times out, or all checks complete successfully.
|
|
12
|
+
*
|
|
13
|
+
* @param outputPath App output path
|
|
14
|
+
* @param timeoutMs Timeout in ms
|
|
15
|
+
* @param initialDelayMs Initial delay before re-checking the condition
|
|
16
|
+
*/
|
|
17
|
+
export declare function isTunnelPreparationComplete(outputPath: string, timeoutMs: number, initialDelayMs?: number): Promise<boolean>;
|
|
3
18
|
/**
|
|
4
19
|
* Starts the `forge tunnel` process in the app's output directory. The execution of `forge tunnel` will be delayed
|
|
5
20
|
* until all configured Custom UI dev servers are listening on their configured tunnel port.
|
|
@@ -12,10 +27,11 @@ import { TunnelExecutorOptions } from '../schema';
|
|
|
12
27
|
* @param context Executor context for this call
|
|
13
28
|
*/
|
|
14
29
|
export default function runTunnel(options: TunnelExecutorOptions & {
|
|
15
|
-
|
|
30
|
+
customUIProjectConfigs: {
|
|
16
31
|
projectName: string;
|
|
17
32
|
port: number;
|
|
18
33
|
}[];
|
|
19
34
|
}, context: ExecutorContext): Promise<{
|
|
35
|
+
id: 'tunnel';
|
|
20
36
|
success: boolean;
|
|
21
37
|
}>;
|
|
@@ -1,11 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTunnelPreparationComplete = isTunnelPreparationComplete;
|
|
3
4
|
exports.default = runTunnel;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const process = tslib_1.__importStar(require("node:process"));
|
|
8
9
|
const wait_until_server_is_listening_1 = require("./wait-until-server-is-listening");
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the tunnel executor is ready to run the Forge tunnel process.
|
|
14
|
+
*
|
|
15
|
+
* Checks if:
|
|
16
|
+
* - the manifest.yml exists in the output path
|
|
17
|
+
* - the `src` directory in the output path is non-empty
|
|
18
|
+
*
|
|
19
|
+
* This will perform these checks repeatedly with exponential backoff until,
|
|
20
|
+
* either the function times out, or all checks complete successfully.
|
|
21
|
+
*
|
|
22
|
+
* @param outputPath App output path
|
|
23
|
+
* @param timeoutMs Timeout in ms
|
|
24
|
+
* @param initialDelayMs Initial delay before re-checking the condition
|
|
25
|
+
*/
|
|
26
|
+
function isTunnelPreparationComplete(outputPath_1, timeoutMs_1) {
|
|
27
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (outputPath, timeoutMs, initialDelayMs = 200) {
|
|
28
|
+
const manifestExists = () => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
return (_b = (_a = (0, node_fs_1.statSync)(node_path_1.default.join(outputPath, 'manifest.yml'), {
|
|
31
|
+
throwIfNoEntry: false,
|
|
32
|
+
})) === null || _a === void 0 ? void 0 : _a.isFile()) !== null && _b !== void 0 ? _b : false;
|
|
33
|
+
};
|
|
34
|
+
const isOutputPathSrcDirNonEmpty = () => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return (_b = (((_a = (0, node_fs_1.statSync)(node_path_1.default.join(outputPath, 'src'), {
|
|
37
|
+
throwIfNoEntry: false,
|
|
38
|
+
})) === null || _a === void 0 ? void 0 : _a.isDirectory()) &&
|
|
39
|
+
(0, node_fs_1.readdirSync)(node_path_1.default.join(outputPath, 'src')).length > 0)) !== null && _b !== void 0 ? _b : false;
|
|
40
|
+
};
|
|
41
|
+
const timeout = new Promise((_, reject) => {
|
|
42
|
+
setTimeout(() => reject(new Error(`Timeout: Tunnel preparation not completed within ${timeoutMs} ms`)), timeoutMs);
|
|
43
|
+
});
|
|
44
|
+
const tunnelReadyCondition = function () {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
let delay = initialDelayMs;
|
|
47
|
+
while (true) {
|
|
48
|
+
try {
|
|
49
|
+
if (manifestExists() && isOutputPathSrcDirNonEmpty()) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new Error(`Unexpected error checking tunnel preparation complete: ${err}`);
|
|
55
|
+
}
|
|
56
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
57
|
+
delay *= 2;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
return Promise.race([tunnelReadyCondition(), timeout]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
9
64
|
/**
|
|
10
65
|
* Starts the `forge tunnel` process in the app's output directory. The execution of `forge tunnel` will be delayed
|
|
11
66
|
* until all configured Custom UI dev servers are listening on their configured tunnel port.
|
|
@@ -19,23 +74,26 @@ const wait_until_server_is_listening_1 = require("./wait-until-server-is-listeni
|
|
|
19
74
|
*/
|
|
20
75
|
function runTunnel(options, context) {
|
|
21
76
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
77
|
+
if (options.customUIProjectConfigs.length > 0) {
|
|
78
|
+
devkit_1.logger.info(`Wait for all Custom UI 'serve' targets to have started and servers are listening...`);
|
|
79
|
+
yield Promise.all(options.customUIProjectConfigs.map(({ port }) => (0, wait_until_server_is_listening_1.waitUntilServerIsListening)(port, context)));
|
|
80
|
+
devkit_1.logger.info(`All Custom UI 'serve' targets have started and servers are listening`);
|
|
81
|
+
}
|
|
25
82
|
const args = [
|
|
26
83
|
'tunnel',
|
|
27
84
|
...(options.verbose === true ? ['--verbose'] : []),
|
|
28
85
|
...(options.debug === true ? ['--debug'] : []),
|
|
29
86
|
];
|
|
30
87
|
const command = `forge ${args.join(' ')}`;
|
|
31
|
-
devkit_1.logger.
|
|
88
|
+
devkit_1.logger.info(`Running: > ${command}`);
|
|
32
89
|
// https://2ality.com/2018/05/child-process-streams.html#running-commands-in-child-processes
|
|
33
|
-
const tunnelProcess = (0,
|
|
90
|
+
const tunnelProcess = (0, node_child_process_1.spawn)('forge', args, {
|
|
34
91
|
cwd: options.outputPath,
|
|
35
92
|
env: Object.assign(Object.assign({}, process.env), {
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
93
|
+
// Unset NODE_ENV, if this is set to 'development' it may cause issues
|
|
94
|
+
// starting the tunnel process
|
|
95
|
+
// https://stackoverflow.com/questions/69566849/installing-forge-cli-is-bringing-spawn-ts-node-enoent-error
|
|
96
|
+
NODE_ENV: undefined }),
|
|
39
97
|
stdio: 'inherit',
|
|
40
98
|
shell: true,
|
|
41
99
|
});
|
|
@@ -44,6 +102,7 @@ function runTunnel(options, context) {
|
|
|
44
102
|
if (code === 0) {
|
|
45
103
|
devkit_1.logger.info('Exiting the forge tunnel process...');
|
|
46
104
|
resolve({
|
|
105
|
+
id: 'tunnel',
|
|
47
106
|
success: true,
|
|
48
107
|
});
|
|
49
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-tunnel.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/tunnel/lib/run-tunnel.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"run-tunnel.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/tunnel/lib/run-tunnel.ts"],"names":[],"mappings":";;AAsBA,kEA+CC;AAaD,4BAkEC;;AApJD,uCAAqD;AACrD,2DAA2C;AAC3C,8DAAwC;AAExC,qFAA8E;AAC9E,qCAAgD;AAChD,kEAA6B;AAE7B;;;;;;;;;;;;;GAaG;AACH,SA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G;gBACd,sEAAsE;gBACtE,8BAA8B;gBAC9B,2GAA2G;gBAC3G,QAAQ,EAAE,SAAS,GACpB;YACD,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,OAAO,IAAI,OAAO,CAAqC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC1C,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBACf,eAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;oBACnD,OAAO,CAAC;wBACN,EAAE,EAAE,QAAQ;wBACZ,OAAO,EAAE,IAAI;qBACd,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,MAAM,CACJ,IAAI,KAAK,CAAC,mDAAmD,GAAG,IAAI,CAAC,CACtE,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;YACH,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;gBACzC,MAAM,CAAC,IAAI,KAAK,CAAC,+BAA+B,GAAG,GAAG,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startCustomUIs = startCustomUIs;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
function startCustomUIs(customUIProjectConfigs, context) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const customUIIters = [];
|
|
9
|
+
for (const config of customUIProjectConfigs) {
|
|
10
|
+
customUIIters.push(yield (0, devkit_1.runExecutor)({ project: config.projectName, target: 'serve' }, { port: config.port }, context));
|
|
11
|
+
}
|
|
12
|
+
return customUIIters;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=start-custom-uis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-custom-uis.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/tunnel/lib/start-custom-uis.ts"],"names":[],"mappings":";;AAEA,wCAgBC;;AAlBD,uCAA0D;AAE1D,SAAsB,cAAc,CAClC,sBAA+D,EAC/D,OAAwB;;QAExB,MAAM,aAAa,GAA0C,EAAE,CAAC;QAEhE,KAAK,MAAM,MAAM,IAAI,sBAAsB,EAAE,CAAC;YAC5C,aAAa,CAAC,IAAI,CAChB,MAAM,IAAA,oBAAW,EACf,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EAChD,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EACrB,OAAO,CACR,CACF,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"description": "Run Forge tunnel in verbose mode.",
|
|
23
23
|
"alias": "v",
|
|
24
24
|
"default": false
|
|
25
|
+
},
|
|
26
|
+
"preTunnelTimeout": {
|
|
27
|
+
"type": "number",
|
|
28
|
+
"description": "Max milliseconds to wait for tunnel preparation tasks.",
|
|
29
|
+
"default": 5000,
|
|
30
|
+
"visible": false
|
|
25
31
|
}
|
|
26
32
|
},
|
|
27
33
|
"required": ["outputPath"]
|
|
@@ -19,6 +19,11 @@ module.exports = {
|
|
|
19
19
|
assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
|
|
20
20
|
optimization: false,
|
|
21
21
|
outputHashing: 'none',
|
|
22
|
+
// Do not delete all the files in the output path. This is required to maintain the
|
|
23
|
+
// manifest.yml in the output path when running the tunnel executor. By default,
|
|
24
|
+
// Webpack still cleans the src folder in the output directory (dist/apps/<my-app>/src)
|
|
25
|
+
// but not the project root (refer to Webpack option `output.clean`).
|
|
26
|
+
deleteOutputPath: false,
|
|
22
27
|
})
|
|
23
28
|
],
|
|
24
29
|
};
|
|
@@ -5,7 +5,7 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const get_register_config_1 = require("../shared/targets/get-register-config");
|
|
8
|
-
const
|
|
8
|
+
const get_tunnel_config_1 = require("../shared/targets/get-tunnel-config");
|
|
9
9
|
const get_deploy_config_1 = require("../shared/targets/get-deploy-config");
|
|
10
10
|
const get_install_config_1 = require("../shared/targets/get-install-config");
|
|
11
11
|
const get_forge_cli_config_1 = require("../shared/targets/get-forge-cli-config");
|
|
@@ -17,7 +17,7 @@ const buildForgeProjectTargets = (projectRoot) => {
|
|
|
17
17
|
const targets = {};
|
|
18
18
|
targets.register = (0, get_register_config_1.getRegisterConfig)({ outputPath });
|
|
19
19
|
targets.package = (0, get_package_config_1.getPackageConfig)({ outputPath });
|
|
20
|
-
targets.
|
|
20
|
+
targets.tunnel = (0, get_tunnel_config_1.getTunnelConfig)({ outputPath });
|
|
21
21
|
targets.deploy = (0, get_deploy_config_1.getDeployConfig)({ outputPath });
|
|
22
22
|
targets.install = (0, get_install_config_1.getInstallConfig)({ outputPath });
|
|
23
23
|
targets.forge = (0, get_forge_cli_config_1.getForgeCliConfig)({ outputPath });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-nodes.js","sourceRoot":"","sources":["../../../../../packages/nx-forge/src/graph/create-nodes.ts"],"names":[],"mappings":";;;AAAA,2BAAiC;AACjC,+BAAqC;AACrC,uCAKoB;AACpB,+EAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"create-nodes.js","sourceRoot":"","sources":["../../../../../packages/nx-forge/src/graph/create-nodes.ts"],"names":[],"mappings":";;;AAAA,2BAAiC;AACjC,+BAAqC;AACrC,uCAKoB;AACpB,+EAA0E;AAC1E,2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,EAAC,gBAAgB,CAAC,CAAC;IAE9C,uDAAuD;IACvD,MAAM,YAAY,GAAG,IAAA,gBAAW,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;IAC3E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL,QAAQ,EAAE;YACR,CAAC,WAAW,CAAC,EAAE;gBACb,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,wBAAwB,CAAC,WAAW,CAAC;aAC/C;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.getTunnelConfig = getTunnelConfig;
|
|
4
|
+
function getTunnelConfig(options) {
|
|
5
5
|
return {
|
|
6
6
|
executor: '@toolsplus/nx-forge:tunnel',
|
|
7
7
|
options: {
|
|
@@ -13,4 +13,4 @@ function getServeConfig(options) {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=get-
|
|
16
|
+
//# sourceMappingURL=get-tunnel-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tunnel-config.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/shared/targets/get-tunnel-config.ts"],"names":[],"mappings":";;AAKA,0CAaC;AAbD,SAAgB,eAAe,CAC7B,OAA+B;IAE/B,OAAO;QACL,QAAQ,EAAE,4BAA4B;QACtC,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,uBAAuB;SACrC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-serve-config.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/shared/targets/get-serve-config.ts"],"names":[],"mappings":";;AAKA,wCAaC;AAbD,SAAgB,cAAc,CAC5B,OAA8B;IAE9B,OAAO;QACL,QAAQ,EAAE,4BAA4B;QACtC,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,uBAAuB;SACrC;KACF,CAAC;AACJ,CAAC"}
|