@intuned/runtime-dev 1.3.17-cdp.1 → 1.3.17-ws.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/dist/commands/intuned-cli/controller/save.js +14 -8
- package/dist/commands/intuned-cli/helpers/backend.js +1 -1
- package/dist/commands/intuned-cli/main.js +21 -8
- package/dist/common/launchBrowser.d.ts +0 -2
- package/dist/common/launchBrowser.js +0 -18
- package/dist/common/playwrightContext.js +1 -5
- package/package.json +1 -1
|
@@ -96,18 +96,24 @@ async function runSaveProject(projectName, auth) {
|
|
|
96
96
|
${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
|
|
97
97
|
${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
|
|
98
98
|
(0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
|
|
99
|
+
return;
|
|
99
100
|
}
|
|
100
101
|
const envContent = await fs.readFile(dotEnvPath, "utf-8");
|
|
101
102
|
const dotenvContent = dotenv.parse(envContent);
|
|
102
103
|
let contentToAppend = "";
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const projectCredentialsEnvVars = {
|
|
105
|
+
[_constants2.PROJECT_ID_ENV_VAR_KEY]: projectId,
|
|
106
|
+
[_constants2.WORKSPACE_ID_ENV_VAR_KEY]: workspaceId,
|
|
107
|
+
[_constants2.API_KEY_ENV_VAR_KEY]: apiKey
|
|
108
|
+
};
|
|
109
|
+
for (const key in projectCredentialsEnvVars) {
|
|
110
|
+
if (dotenvContent[key] === projectCredentialsEnvVars[key]) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (dotenvContent[key]) {
|
|
114
|
+
(0, _terminal.terminal)(`^yWarning: Existing ${key} in .env has invalid value. Appending correct value.^:\n`);
|
|
115
|
+
}
|
|
116
|
+
contentToAppend += `${key}=${projectCredentialsEnvVars[key]}\n`;
|
|
111
117
|
}
|
|
112
118
|
if (contentToAppend) {
|
|
113
119
|
await fs.appendFile(dotEnvPath, contentToAppend + "\n");
|
|
@@ -9,7 +9,7 @@ var _constants = require("../../../common/constants");
|
|
|
9
9
|
var _errors = require("./errors");
|
|
10
10
|
var _intunedJson = require("./intunedJson");
|
|
11
11
|
async function getAuthCredentials(options) {
|
|
12
|
-
const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId;
|
|
12
|
+
const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId || process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
|
|
13
13
|
const apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
14
14
|
if (!workspaceId) {
|
|
15
15
|
throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
4
4
|
var _constants = require("../../common/constants");
|
|
5
5
|
var _backend = require("./helpers/backend");
|
|
6
|
-
var
|
|
7
|
-
var _helpers = require("./helpers");
|
|
6
|
+
var _intunedJson = require("../../common/intunedJson");
|
|
8
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
10
|
require("../../common/binStartupScript");
|
|
10
11
|
_dotenv.default.config({
|
|
11
12
|
path: `.env`
|
|
@@ -15,9 +16,21 @@ process.env.RUN_ENVIRONMENT = "AUTHORING";
|
|
|
15
16
|
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
16
17
|
process.env.FUNCTIONS_DOMAIN = (0, _backend.getBaseUrl)().replace(/\/$/, "");
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
void (async () => {
|
|
20
|
+
const intunedJson = await (0, _intunedJson.loadIntunedJson)();
|
|
21
|
+
if (intunedJson.isOk() && intunedJson.value.workspaceId) {
|
|
22
|
+
process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY] = intunedJson.value.workspaceId;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
program
|
|
26
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands")));
|
|
27
|
+
const {
|
|
28
|
+
withCLIContext
|
|
29
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./helpers/context")));
|
|
30
|
+
await withCLIContext(async () => {
|
|
31
|
+
program.configureHelp({
|
|
32
|
+
sortSubcommands: true
|
|
33
|
+
});
|
|
34
|
+
program.parse(process.argv);
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as playwright from "playwright";
|
|
2
|
-
import { Result } from "neverthrow";
|
|
3
2
|
export interface Proxy {
|
|
4
3
|
server: string;
|
|
5
4
|
username: string;
|
|
@@ -25,7 +24,6 @@ export declare function launchChromium(options: LaunchChromiumCdpOptions): Promi
|
|
|
25
24
|
export declare function getBrowserExecutablePath(): Promise<string | undefined>;
|
|
26
25
|
export declare function launchBrowser(options: Omit<LaunchChromiumStandaloneOptions, "executablePath"> | LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
27
26
|
export declare function getLocalCdpAddress(port: number): string;
|
|
28
|
-
export declare function getCdpWebSocketUrl(cdpAddress: string): Promise<Result<string, string>>;
|
|
29
27
|
export declare function getHeadlessUserAgent({ executablePath, args, ignoreDefaultArgs, }: {
|
|
30
28
|
executablePath?: string;
|
|
31
29
|
args?: string[];
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getBrowserExecutablePath = getBrowserExecutablePath;
|
|
7
|
-
exports.getCdpWebSocketUrl = getCdpWebSocketUrl;
|
|
8
7
|
exports.getHeadlessUserAgent = getHeadlessUserAgent;
|
|
9
8
|
exports.getLocalCdpAddress = getLocalCdpAddress;
|
|
10
9
|
exports.launchBrowser = launchBrowser;
|
|
@@ -18,8 +17,6 @@ var _child_process = require("child_process");
|
|
|
18
17
|
var _extensionsHelpers = require("./extension/extensionsHelpers");
|
|
19
18
|
var _intunedExtensionServer = require("./extension/intunedExtensionServer");
|
|
20
19
|
var _util = require("util");
|
|
21
|
-
var _neverthrow = require("neverthrow");
|
|
22
|
-
var _zod = require("zod");
|
|
23
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -176,21 +173,6 @@ async function getBraveExecutablePath() {
|
|
|
176
173
|
function getLocalCdpAddress(port) {
|
|
177
174
|
return `http://localhost:${port}`;
|
|
178
175
|
}
|
|
179
|
-
async function getCdpWebSocketUrl(cdpAddress) {
|
|
180
|
-
const response = await fetch(`${cdpAddress}/json/version`);
|
|
181
|
-
if (!response.ok) {
|
|
182
|
-
return (0, _neverthrow.err)(`Failed to get CDP WebSocket URL from ${cdpAddress}: ${response.status} ${response.statusText}`);
|
|
183
|
-
}
|
|
184
|
-
const data = await response.json();
|
|
185
|
-
const cdpJsonVersionResponseSchema = _zod.z.object({
|
|
186
|
-
webSocketDebuggerUrl: _zod.z.string().url()
|
|
187
|
-
});
|
|
188
|
-
const parseResult = cdpJsonVersionResponseSchema.safeParse(data);
|
|
189
|
-
if (!parseResult.success) {
|
|
190
|
-
return (0, _neverthrow.err)(`Invalid CDP version response from ${cdpAddress}: ${JSON.stringify(parseResult.error.format())}`);
|
|
191
|
-
}
|
|
192
|
-
return (0, _neverthrow.ok)(parseResult.data.webSocketDebuggerUrl);
|
|
193
|
-
}
|
|
194
176
|
async function waitOnCdpAddress(cdpAddress) {
|
|
195
177
|
const cdpAddressWithoutProtocol = cdpAddress.replace("http://", "").replace("https://", "").replace("localhost", "127.0.0.1");
|
|
196
178
|
await (0, _waitOn.default)({
|
|
@@ -71,6 +71,7 @@ async function withPlaywrightContext({
|
|
|
71
71
|
const port = await (0, _portfinder.getPort)({
|
|
72
72
|
port: 9222
|
|
73
73
|
});
|
|
74
|
+
hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
|
|
74
75
|
({
|
|
75
76
|
context,
|
|
76
77
|
page
|
|
@@ -80,14 +81,9 @@ async function withPlaywrightContext({
|
|
|
80
81
|
downloadsPath,
|
|
81
82
|
cdpPort: port
|
|
82
83
|
}));
|
|
83
|
-
hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
|
|
84
84
|
}
|
|
85
85
|
let hookResult;
|
|
86
86
|
try {
|
|
87
|
-
const wsUrlResult = await (0, _launchBrowser.getCdpWebSocketUrl)(hookCdpUrl);
|
|
88
|
-
if (wsUrlResult.isOk()) {
|
|
89
|
-
hookCdpUrl = wsUrlResult.value;
|
|
90
|
-
}
|
|
91
87
|
hookResult = await setupContextHook({
|
|
92
88
|
apiName: apiName,
|
|
93
89
|
apiParameters: apiParameters,
|