@intuned/runtime-dev 1.0.6-cli-auth.0.1.4-test → 1.0.6-cli.2
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/WebTemplate.zip +0 -0
- package/bin/intuned-run +3 -0
- package/dist/commands/common/utils/unixSocket.d.ts +0 -1
- package/dist/commands/deploy/deploy.js +10 -23
- package/dist/commands/deploy/utils.d.ts +2 -11
- package/dist/commands/deploy/utils.js +55 -267
- package/dist/commands/init/init.js +4 -3
- package/dist/{common/cli → commands/init}/types.d.ts +0 -22
- package/dist/commands/init/types.js +7 -0
- package/dist/commands/init/utils.d.ts +3 -5
- package/dist/commands/init/utils.js +24 -61
- package/dist/commands/intuned-run/intuned-run.js +35 -0
- package/dist/commands/intuned-run/utils.d.ts +5 -0
- package/dist/commands/intuned-run/utils.js +91 -0
- package/dist/common/asyncLocalStorage/index.d.ts +1 -2
- package/dist/common/asyncLocalStorage/index.js +5 -2
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +2 -3
- package/dist/common/runApi/types.d.ts +2 -2
- package/my-intuned-project/Intuned.json +15 -0
- package/my-intuned-project/api/book-details.ts +46 -0
- package/my-intuned-project/api/books-all.ts +68 -0
- package/my-intuned-project/emp/Intuned.json +18 -0
- package/my-intuned-project/emp/____testParameters/learn/actions/download.json +8 -0
- package/my-intuned-project/emp/____testParameters/learn/actions/fillForm.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/actions/upload.json +8 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/ai-extraction.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/extract-data-from-content.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/markdown-extraction.json +8 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-array-exteractor.json +32 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-object-extractor.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/data-extraction/pdf.json +8 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/fill-and-submit-forms.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/iframes.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/inject-code.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/locators-and-actions.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/navigation.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/network-interception.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/scrape-data.json +1 -0
- package/my-intuned-project/emp/____testParameters/learn/playwright/wait-for-state-change.json +1 -0
- package/my-intuned-project/emp/api/learn/actions/download.ts +71 -0
- package/my-intuned-project/emp/api/learn/actions/fillForm.ts +223 -0
- package/my-intuned-project/emp/api/learn/actions/upload.ts +38 -0
- package/my-intuned-project/emp/api/learn/data-extraction/ai-extraction.ts +72 -0
- package/my-intuned-project/emp/api/learn/data-extraction/extract-data-from-content.ts +76 -0
- package/my-intuned-project/emp/api/learn/data-extraction/markdown-extraction.ts +47 -0
- package/my-intuned-project/emp/api/learn/data-extraction/optimized-array-exteractor.ts +49 -0
- package/my-intuned-project/emp/api/learn/data-extraction/optimized-object-extractor.ts +54 -0
- package/my-intuned-project/emp/api/learn/data-extraction/pdf.ts +123 -0
- package/my-intuned-project/emp/api/learn/playwright/fill-and-submit-forms.ts +73 -0
- package/my-intuned-project/emp/api/learn/playwright/iframes.ts +22 -0
- package/my-intuned-project/emp/api/learn/playwright/inject-code.ts +40 -0
- package/my-intuned-project/emp/api/learn/playwright/locators-and-actions.ts +58 -0
- package/my-intuned-project/emp/api/learn/playwright/navigation.ts +25 -0
- package/my-intuned-project/emp/api/learn/playwright/network-interception.ts +43 -0
- package/my-intuned-project/emp/api/learn/playwright/scrape-data.ts +58 -0
- package/my-intuned-project/emp/api/learn/playwright/wait-for-state-change.ts +44 -0
- package/my-intuned-project/emp/api/sample.ts +15 -0
- package/my-intuned-project/emp/package.json +31 -0
- package/my-intuned-project/emp/utils/helpers.ts +3 -0
- package/my-intuned-project/emp/yarn.lock +4530 -0
- package/my-intuned-project/package.json +36 -0
- package/my-intuned-project/params/bookInput.json +3 -0
- package/my-intuned-project/yarn.lock +4539 -0
- package/package.json +10 -14
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -285
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/common/projectExclusions.d.ts +0 -2
- package/dist/commands/common/projectExclusions.js +0 -8
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +0 -92
- package/dist/common/cli/constants.d.ts +0 -33
- package/dist/common/cli/constants.js +0 -39
- package/dist/common/cli/types.js +0 -13
- package/dist/common/cli/utils.d.ts +0 -6
- package/dist/common/cli/utils.js +0 -35
- /package/bin/{deploy → intuned-deploy} +0 -0
- /package/bin/{init → intuned-init} +0 -0
- /package/dist/commands/{cli-auth-sessions/check.d.ts → intuned-run/intuned-run.d.ts} +0 -0
package/WebTemplate.zip
ADDED
|
Binary file
|
package/bin/intuned-run
ADDED
|
@@ -4,41 +4,28 @@
|
|
|
4
4
|
var _commander = require("commander");
|
|
5
5
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
6
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
-
var _utils = require("
|
|
8
|
-
var _utils2 = require("
|
|
7
|
+
var _utils = require("../init/utils");
|
|
8
|
+
var _utils2 = require("./utils");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
_dotenv.default.config({
|
|
11
11
|
path: `.env`
|
|
12
12
|
});
|
|
13
13
|
_commander.program.description("Deploy an Intuned project to be public").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action(async (projectName, options) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
isValid,
|
|
17
|
-
errorMessage
|
|
18
|
-
} = await (0, _utils.validateIntunedProject)();
|
|
19
|
-
if (!isValid) {
|
|
20
|
-
const userErrorMesage = `Project to be deployed is not a valid Intuned project: ${errorMessage}, modify and check again`;
|
|
21
|
-
throw new Error(userErrorMesage);
|
|
22
|
-
}
|
|
23
|
-
const _projectName = projectName || (await (0, _utils2.getSettingIntunedJSON)("projectName"));
|
|
24
|
-
if (!_projectName) {
|
|
15
|
+
if (!projectName) {
|
|
25
16
|
throw new Error("Project name is required");
|
|
26
17
|
}
|
|
27
|
-
const projectNameValidation = (0,
|
|
18
|
+
const projectNameValidation = (0, _utils2.validateProjectName)(projectName);
|
|
28
19
|
if (!projectNameValidation.isValid) {
|
|
29
20
|
throw new Error(projectNameValidation.errorMessage);
|
|
30
21
|
}
|
|
31
|
-
const auth =
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
deployErrorMessage
|
|
36
|
-
} = await (0, _utils.deployProject)(_projectName, auth);
|
|
37
|
-
if (!deployDone) {
|
|
38
|
-
throw new Error(`Project not deployed: ${deployErrorMessage}`);
|
|
22
|
+
const auth = (0, _utils.getAuthCredentials)(options);
|
|
23
|
+
const deployStarted = await (0, _utils2.deployProject)(projectName, auth);
|
|
24
|
+
if (!deployStarted) {
|
|
25
|
+
throw new Error("Project not deployed");
|
|
39
26
|
}
|
|
40
|
-
const url =
|
|
41
|
-
console.log(_chalk.default.green(`\n
|
|
27
|
+
const url = `https://rauf-2.intuned-team-local.com/projects`;
|
|
28
|
+
console.log(_chalk.default.green(`\n🚀 Project "${projectName}" started deployment successfully!` + `\n\nYou can check your project on the platform: ${_chalk.default.bold(url)}\n`));
|
|
42
29
|
} catch (error) {
|
|
43
30
|
console.error(_chalk.default.red(`\n${error.message}`));
|
|
44
31
|
process.exit(1);
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { AuthCredentials, FileSystemTree } from "
|
|
1
|
+
import { AuthCredentials, FileSystemTree } from "../init/types";
|
|
2
2
|
export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
|
|
3
|
-
export declare function deployProject(projectName: string, auth: AuthCredentials): Promise<
|
|
4
|
-
deployDone: boolean;
|
|
5
|
-
projectId?: string;
|
|
6
|
-
deployErrorMessage?: string;
|
|
7
|
-
}>;
|
|
3
|
+
export declare function deployProject(projectName: string, auth: AuthCredentials): Promise<boolean>;
|
|
8
4
|
export declare const validateProjectName: (projectName: string) => {
|
|
9
5
|
isValid: boolean;
|
|
10
6
|
errorMessage?: string;
|
|
11
7
|
};
|
|
12
|
-
export declare const validateIntunedProject: () => Promise<{
|
|
13
|
-
isValid: boolean;
|
|
14
|
-
errorMessage?: string;
|
|
15
|
-
}>;
|
|
16
|
-
export declare const runBuild: () => Promise<boolean>;
|
|
@@ -5,25 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertProjectToCodeTree = convertProjectToCodeTree;
|
|
7
7
|
exports.deployProject = deployProject;
|
|
8
|
-
exports.validateProjectName =
|
|
9
|
-
var fs = _interopRequireWildcard(require("fs
|
|
8
|
+
exports.validateProjectName = void 0;
|
|
9
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
10
10
|
var path = _interopRequireWildcard(require("path"));
|
|
11
11
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
12
|
var _minimatch = require("minimatch");
|
|
13
13
|
var _zod = require("zod");
|
|
14
|
-
var _child_process = require("child_process");
|
|
15
|
-
var _util = require("util");
|
|
16
|
-
var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
|
|
17
|
-
var _constants = require("../../common/cli/constants");
|
|
18
|
-
var _utils = require("../../common/cli/utils");
|
|
19
|
-
var _utils2 = require("../init/utils");
|
|
20
|
-
var _lodash = require("lodash");
|
|
21
|
-
var _uuid = require("uuid");
|
|
22
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
15
|
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); }
|
|
24
16
|
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; }
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
function formatBytes(bytes) {
|
|
18
|
+
if (bytes === 0) return "0 Bytes";
|
|
19
|
+
const k = 1024;
|
|
20
|
+
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
21
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
22
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
23
|
+
}
|
|
24
|
+
function matchesGitignorePatterns(filePath, patterns, projectPath) {
|
|
27
25
|
const relativePath = path.relative(projectPath, filePath);
|
|
28
26
|
if (relativePath.startsWith("node_modules")) {
|
|
29
27
|
return true;
|
|
@@ -47,7 +45,7 @@ function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
|
47
45
|
const entries = fs.readdirSync(dirPath);
|
|
48
46
|
for (const entry of entries) {
|
|
49
47
|
const fullPath = path.join(dirPath, entry);
|
|
50
|
-
if (
|
|
48
|
+
if (matchesGitignorePatterns(fullPath, ignorePatterns, projectPath)) {
|
|
51
49
|
continue;
|
|
52
50
|
}
|
|
53
51
|
try {
|
|
@@ -69,17 +67,45 @@ function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
|
69
67
|
return results;
|
|
70
68
|
}
|
|
71
69
|
async function convertProjectToCodeTree(projectPath) {
|
|
72
|
-
const
|
|
70
|
+
const defaultExcludes = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo"];
|
|
71
|
+
let ignorePatterns = [...defaultExcludes];
|
|
72
|
+
let currentDir = path.normalize(projectPath);
|
|
73
|
+
let gitignoreFound = false;
|
|
74
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
75
|
+
const gitignorePath = path.join(currentDir, ".gitignore");
|
|
76
|
+
if (fs.existsSync(gitignorePath)) {
|
|
77
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, "utf-8").split("\n");
|
|
78
|
+
ignorePatterns = [...ignorePatterns, ...gitignoreContent];
|
|
79
|
+
console.log(`Found .gitignore file: ${_chalk.default.cyan.bold(gitignorePath)}`);
|
|
80
|
+
gitignoreFound = true;
|
|
81
|
+
break;
|
|
82
|
+
} else {
|
|
83
|
+
currentDir = path.dirname(currentDir);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const filesToDeploy = listFilesNotIgnored(projectPath, ignorePatterns);
|
|
87
|
+
let totalSize = 0;
|
|
88
|
+
for (const file of filesToDeploy) {
|
|
89
|
+
try {
|
|
90
|
+
const stats = fs.statSync(path.join(projectPath, file));
|
|
91
|
+
totalSize += stats.size;
|
|
92
|
+
} catch (error) {}
|
|
93
|
+
}
|
|
73
94
|
console.log(_chalk.default.cyan("\nFiles to be deployed:"));
|
|
74
|
-
|
|
75
|
-
|
|
95
|
+
if (filesToDeploy.length > 100) {
|
|
96
|
+
console.log(_chalk.default.yellow(` ${filesToDeploy.length} files (too many to display)`));
|
|
97
|
+
} else {
|
|
98
|
+
const filesToDeployText = "\n " + filesToDeploy.join("\n ");
|
|
99
|
+
console.log(filesToDeployText);
|
|
100
|
+
}
|
|
101
|
+
console.log(_chalk.default.cyan(`\nSummary: ${filesToDeploy.length} files, ${formatBytes(totalSize)}`));
|
|
76
102
|
function readDirectory(dirPath) {
|
|
77
103
|
const tree = {};
|
|
78
104
|
try {
|
|
79
105
|
const entries = fs.readdirSync(dirPath);
|
|
80
106
|
for (const entry of entries) {
|
|
81
107
|
const entryPath = path.join(dirPath, entry);
|
|
82
|
-
if (
|
|
108
|
+
if (matchesGitignorePatterns(entryPath, ignorePatterns, projectPath)) {
|
|
83
109
|
continue;
|
|
84
110
|
}
|
|
85
111
|
try {
|
|
@@ -112,9 +138,8 @@ async function convertProjectToCodeTree(projectPath) {
|
|
|
112
138
|
}
|
|
113
139
|
return tree;
|
|
114
140
|
}
|
|
115
|
-
console.log(_chalk.default.cyan("\
|
|
141
|
+
console.log(_chalk.default.cyan("\nBuilding project..."));
|
|
116
142
|
const tree = readDirectory(projectPath);
|
|
117
|
-
await mapToIDEParams(tree);
|
|
118
143
|
return tree;
|
|
119
144
|
}
|
|
120
145
|
async function deployProject(projectName, auth) {
|
|
@@ -122,7 +147,7 @@ async function deployProject(projectName, auth) {
|
|
|
122
147
|
workspaceId,
|
|
123
148
|
apiKey
|
|
124
149
|
} = auth;
|
|
125
|
-
const baseUrl =
|
|
150
|
+
const baseUrl = "https://rauf-2.intuned-team-local.com";
|
|
126
151
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create`;
|
|
127
152
|
const headers = {
|
|
128
153
|
"x-api-key": apiKey,
|
|
@@ -130,14 +155,9 @@ async function deployProject(projectName, auth) {
|
|
|
130
155
|
};
|
|
131
156
|
const projectPath = process.cwd();
|
|
132
157
|
const codeTree = await convertProjectToCodeTree(projectPath);
|
|
133
|
-
codeTree["tsconfig.json"] = {
|
|
134
|
-
file: {
|
|
135
|
-
contents: JSON.stringify(_constants.tsConfigCli, null, 2)
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
158
|
const deployProjectPayload = {
|
|
139
159
|
name: projectName,
|
|
140
|
-
codeTree,
|
|
160
|
+
codeTree: codeTree,
|
|
141
161
|
isCli: true,
|
|
142
162
|
language: "typescript"
|
|
143
163
|
};
|
|
@@ -147,43 +167,16 @@ async function deployProject(projectName, auth) {
|
|
|
147
167
|
body: JSON.stringify(deployProjectPayload)
|
|
148
168
|
});
|
|
149
169
|
if (!response.ok) {
|
|
150
|
-
if (response.status === 401) {
|
|
151
|
-
throw new Error(`Invalid API key. Please check your API key and try again.`);
|
|
152
|
-
}
|
|
153
170
|
throw new Error(`Error deploying project`);
|
|
154
171
|
}
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
projectId
|
|
164
|
-
} = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
|
|
165
|
-
if (status === "completed" || status === "failed" || status === "not_found") {
|
|
166
|
-
clearInterval(checkInterval);
|
|
167
|
-
resolve(status === "completed" ? {
|
|
168
|
-
deployDone: true,
|
|
169
|
-
projectId
|
|
170
|
-
} : {
|
|
171
|
-
deployDone: false,
|
|
172
|
-
projectId: "",
|
|
173
|
-
deployErrorMessage: message
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
const elapsedTime = Date.now() - startTime;
|
|
177
|
-
if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
|
|
178
|
-
clearInterval(checkInterval);
|
|
179
|
-
reject(new Error(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / 1000 / 60)} minutes`));
|
|
180
|
-
}
|
|
181
|
-
} catch (error) {
|
|
182
|
-
clearInterval(checkInterval);
|
|
183
|
-
reject(error);
|
|
184
|
-
}
|
|
185
|
-
}, 5000);
|
|
186
|
-
});
|
|
172
|
+
const data = await response.json();
|
|
173
|
+
if (response.status === 202) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (!data) {
|
|
177
|
+
throw new Error("Project not deployed");
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
187
180
|
}
|
|
188
181
|
const validateProjectName = projectName => {
|
|
189
182
|
const nameSchema = _zod.z.string().min(1, "Project Name is required").max(50, "Name must be 50 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
@@ -200,209 +193,4 @@ const validateProjectName = projectName => {
|
|
|
200
193
|
isValid: true
|
|
201
194
|
};
|
|
202
195
|
};
|
|
203
|
-
exports.validateProjectName = validateProjectName;
|
|
204
|
-
const validateIntunedProject = async () => {
|
|
205
|
-
const currentDirectoryToDeploy = process.cwd();
|
|
206
|
-
const validationSteps = [{
|
|
207
|
-
name: "build",
|
|
208
|
-
check: async () => {
|
|
209
|
-
try {
|
|
210
|
-
const buildResult = await runBuild();
|
|
211
|
-
if (!buildResult) {
|
|
212
|
-
return {
|
|
213
|
-
isValid: false,
|
|
214
|
-
errorMessage: "Build failed"
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
isValid: true
|
|
219
|
-
};
|
|
220
|
-
} catch (error) {
|
|
221
|
-
return {
|
|
222
|
-
isValid: false,
|
|
223
|
-
errorMessage: "Build failed"
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}, {
|
|
228
|
-
name: "package.json",
|
|
229
|
-
check: async () => {
|
|
230
|
-
try {
|
|
231
|
-
var _packageJson$dependen;
|
|
232
|
-
const packageJsonPath = path.join(currentDirectoryToDeploy, "package.json");
|
|
233
|
-
await fs.exists(packageJsonPath);
|
|
234
|
-
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, {
|
|
235
|
-
encoding: "utf-8"
|
|
236
|
-
}));
|
|
237
|
-
const userCodePlaywrightVersion = (_packageJson$dependen = packageJson.dependencies) === null || _packageJson$dependen === void 0 ? void 0 : _packageJson$dependen.playwright;
|
|
238
|
-
if (userCodePlaywrightVersion !== _constants.CURRENT_PLAYWRIGHT_VERSION) {
|
|
239
|
-
return {
|
|
240
|
-
isValid: false,
|
|
241
|
-
errorMessage: `Playwright version mismatch: expected ${_constants.CURRENT_PLAYWRIGHT_VERSION}, found ${userCodePlaywrightVersion || "none"}`
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return {
|
|
245
|
-
isValid: true
|
|
246
|
-
};
|
|
247
|
-
} catch (error) {
|
|
248
|
-
return {
|
|
249
|
-
isValid: false,
|
|
250
|
-
errorMessage: "Package.json file not found or cannot be read"
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}, {
|
|
255
|
-
name: "Intuned.json",
|
|
256
|
-
check: async () => {
|
|
257
|
-
try {
|
|
258
|
-
const intunedJsonPath = path.join(currentDirectoryToDeploy, "Intuned.json");
|
|
259
|
-
await fs.exists(intunedJsonPath);
|
|
260
|
-
return {
|
|
261
|
-
isValid: true
|
|
262
|
-
};
|
|
263
|
-
} catch (error) {
|
|
264
|
-
return {
|
|
265
|
-
isValid: false,
|
|
266
|
-
errorMessage: "Intuned.json file not found"
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
name: "api folder",
|
|
272
|
-
check: async () => {
|
|
273
|
-
try {
|
|
274
|
-
const apiFolderPath = path.join(currentDirectoryToDeploy, "api");
|
|
275
|
-
await fs.access(apiFolderPath);
|
|
276
|
-
return {
|
|
277
|
-
isValid: true
|
|
278
|
-
};
|
|
279
|
-
} catch (error) {
|
|
280
|
-
return {
|
|
281
|
-
isValid: false,
|
|
282
|
-
errorMessage: "API folder not found"
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}];
|
|
287
|
-
for (const step of validationSteps) {
|
|
288
|
-
const result = await step.check();
|
|
289
|
-
if (!result.isValid) {
|
|
290
|
-
return result;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
isValid: true
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
exports.validateIntunedProject = validateIntunedProject;
|
|
298
|
-
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
299
|
-
try {
|
|
300
|
-
const baseUrl = (0, _utils.getBaseUrl)();
|
|
301
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create/${projectName}/result`;
|
|
302
|
-
const headers = {
|
|
303
|
-
"x-api-key": apiKey,
|
|
304
|
-
"Content-Type": "application/json"
|
|
305
|
-
};
|
|
306
|
-
const response = await fetch(url, {
|
|
307
|
-
headers,
|
|
308
|
-
method: "GET"
|
|
309
|
-
});
|
|
310
|
-
if (response.status === 404) {
|
|
311
|
-
return {
|
|
312
|
-
status: "not_found",
|
|
313
|
-
message: "Project not found"
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
if (!response.ok) {
|
|
317
|
-
throw new Error("Error querying deployment status");
|
|
318
|
-
}
|
|
319
|
-
const data = await response.json();
|
|
320
|
-
if (data.status) {
|
|
321
|
-
return {
|
|
322
|
-
status: data.status,
|
|
323
|
-
message: data.message,
|
|
324
|
-
projectId: data.projectId
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
status: "failed",
|
|
329
|
-
message: `Deployment failed, please try again: ${data.message}`
|
|
330
|
-
};
|
|
331
|
-
} catch (e) {
|
|
332
|
-
throw new Error(`Error during deployment`);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
const runBuild = async () => {
|
|
336
|
-
const currentProjectDirectory = process.cwd();
|
|
337
|
-
console.log(_chalk.default.yellow("Running build..."));
|
|
338
|
-
const distPath = path.join(currentProjectDirectory, "dist");
|
|
339
|
-
if (await fs.exists(distPath)) {
|
|
340
|
-
await fs.remove(distPath);
|
|
341
|
-
}
|
|
342
|
-
const buildCommand = "tsc";
|
|
343
|
-
try {
|
|
344
|
-
await execPromise(buildCommand, {
|
|
345
|
-
cwd: currentProjectDirectory
|
|
346
|
-
});
|
|
347
|
-
console.log(_chalk.default.green("🏗️ Build completed successfully"));
|
|
348
|
-
return true;
|
|
349
|
-
} catch (error) {
|
|
350
|
-
console.error(_chalk.default.red(`Build failed: ${error.message}`));
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
exports.runBuild = runBuild;
|
|
355
|
-
async function mapToIDEParams(tree) {
|
|
356
|
-
if (!tree) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (!tree["parameters"] || (0, _utils2._isFileNode)(tree["parameters"])) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const apiParametersMap = {};
|
|
363
|
-
const cliParameters = Object.keys(tree["parameters"].directory);
|
|
364
|
-
const ____testParameters = {
|
|
365
|
-
directory: {}
|
|
366
|
-
};
|
|
367
|
-
for (const parameterKey of cliParameters) {
|
|
368
|
-
const parameter = tree["parameters"].directory[parameterKey];
|
|
369
|
-
if ((0, _utils2._isDirectoryNode)(parameter)) {
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
if ((0, _lodash.isEmpty)(parameter.file.contents)) {
|
|
373
|
-
continue;
|
|
374
|
-
}
|
|
375
|
-
const parameterPayload = JSON.parse(parameter.file.contents);
|
|
376
|
-
if (!parameterPayload["__api-name"]) {
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
const api = parameterPayload["__api-name"];
|
|
380
|
-
const {
|
|
381
|
-
"__api-name": _,
|
|
382
|
-
...parameterValue
|
|
383
|
-
} = parameterPayload;
|
|
384
|
-
const testParameter = {
|
|
385
|
-
name: parameterKey.replace(".json", ""),
|
|
386
|
-
lastUsed: false,
|
|
387
|
-
id: (0, _uuid.v4)(),
|
|
388
|
-
value: JSON.stringify(parameterValue)
|
|
389
|
-
};
|
|
390
|
-
if (!apiParametersMap[api]) {
|
|
391
|
-
apiParametersMap[api] = [];
|
|
392
|
-
}
|
|
393
|
-
apiParametersMap[api].push(testParameter);
|
|
394
|
-
}
|
|
395
|
-
for (const api in apiParametersMap) {
|
|
396
|
-
if (apiParametersMap[api].length > 0) {
|
|
397
|
-
apiParametersMap[api][apiParametersMap[api].length - 1].lastUsed = true;
|
|
398
|
-
}
|
|
399
|
-
____testParameters.directory[`${api}.json`] = {
|
|
400
|
-
file: {
|
|
401
|
-
contents: JSON.stringify(apiParametersMap[api], null, 2)
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
delete tree["parameters"];
|
|
406
|
-
tree["____testParameters"] = ____testParameters;
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
196
|
+
exports.validateProjectName = validateProjectName;
|
|
@@ -9,11 +9,12 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
9
9
|
_dotenv.default.config({
|
|
10
10
|
path: `.env`
|
|
11
11
|
});
|
|
12
|
-
_commander.program.description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").action(async templateName => {
|
|
12
|
+
_commander.program.description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action(async (templateName, options) => {
|
|
13
13
|
try {
|
|
14
|
+
const auth = (0, _utils.getAuthCredentials)(options);
|
|
14
15
|
const template = await (0, _utils.selectTemplate)(templateName);
|
|
15
|
-
|
|
16
|
-
await (0, _utils.scaffoldProject)(template,
|
|
16
|
+
await (0, _utils.checkEmptyDirectory)();
|
|
17
|
+
await (0, _utils.scaffoldProject)(template, auth);
|
|
17
18
|
} catch (error) {
|
|
18
19
|
console.error(_chalk.default.red(`\n${error.message}`));
|
|
19
20
|
process.exit(1);
|
|
@@ -50,25 +50,3 @@ export interface AuthCredentials {
|
|
|
50
50
|
workspaceId: string;
|
|
51
51
|
apiKey: string;
|
|
52
52
|
}
|
|
53
|
-
export declare enum ApiAuthSessionBehavior {
|
|
54
|
-
PERFORM_CHECK_AND_REFRESH = "PERFORM_CHECK_AND_REFRESH",
|
|
55
|
-
SKIP_CHECK_AND_REFRESH = "SKIP_CHECK_AND_REFRESH"
|
|
56
|
-
}
|
|
57
|
-
export declare const CHECK_FAILED_ERROR_MESSAGE = "Auth session check failed";
|
|
58
|
-
export type AuthSessionType = "API" | "MANUAL";
|
|
59
|
-
export type AuthSessionMetadata = {
|
|
60
|
-
createdAt: string;
|
|
61
|
-
updatedAt: string;
|
|
62
|
-
authSessionId: string;
|
|
63
|
-
authSessionType: AuthSessionType;
|
|
64
|
-
authSessionInput?: Record<string, any>;
|
|
65
|
-
recorderStartUrl?: string;
|
|
66
|
-
recorderEndUrl?: string;
|
|
67
|
-
};
|
|
68
|
-
export interface SessionStorageState {
|
|
69
|
-
origin: string;
|
|
70
|
-
sessionStorage: {
|
|
71
|
-
name: string;
|
|
72
|
-
value: string;
|
|
73
|
-
}[];
|
|
74
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.templateIds = void 0;
|
|
7
|
+
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions", "python-empty"];
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function _isDirectoryNode(node: DirectoryNode | FileNode): node is DirectoryNode;
|
|
3
|
-
export declare function _isFileNode(node: DirectoryNode | FileNode): node is FileNode;
|
|
1
|
+
import { AuthCredentials, FileSystemTree } from "./types";
|
|
4
2
|
export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
|
|
5
|
-
export declare function checkEmptyDirectory(): Promise<
|
|
3
|
+
export declare function checkEmptyDirectory(): Promise<void>;
|
|
6
4
|
export declare function getAuthCredentials(options: any): {
|
|
7
5
|
workspaceId: any;
|
|
8
6
|
apiKey: any;
|
|
9
7
|
};
|
|
10
8
|
export declare function selectTemplate(templateName: any): Promise<any>;
|
|
11
|
-
export declare function scaffoldProject(templateId: string,
|
|
9
|
+
export declare function scaffoldProject(templateId: string, authCredentials: AuthCredentials): Promise<void>;
|