@intuned/runtime-dev 1.0.6-dev.4 ā 1.0.6-test-ping.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/WebTemplate.zip +0 -0
- package/package.json +2 -2
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -34
- package/dist/commands/deploy/utils.d.ts +0 -7
- package/dist/commands/deploy/utils.js +0 -203
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -23
- package/dist/commands/init/types.d.ts +0 -52
- package/dist/commands/init/types.js +0 -7
- package/dist/commands/init/utils.d.ts +0 -9
- package/dist/commands/init/utils.js +0 -145
- package/dist/commands/intuned-run/intuned-run.d.ts +0 -4
- package/dist/commands/intuned-run/intuned-run.js +0 -84
- package/dist/commands/intuned-run/utils.d.ts +0 -1
- package/dist/commands/intuned-run/utils.js +0 -34
package/WebTemplate.zip
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.0.6-
|
|
3
|
+
"version": "1.0.6-test-ping.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -133,4 +133,4 @@
|
|
|
133
133
|
"peerDependencies": {
|
|
134
134
|
"@intuned/runtime": "*"
|
|
135
135
|
}
|
|
136
|
-
}
|
|
136
|
+
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _commander = require("commander");
|
|
5
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
-
var _utils = require("../init/utils");
|
|
8
|
-
var _utils2 = require("./utils");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
_dotenv.default.config({
|
|
11
|
-
path: `.env`
|
|
12
|
-
});
|
|
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
|
-
try {
|
|
15
|
-
if (!projectName) {
|
|
16
|
-
throw new Error("Project name is required");
|
|
17
|
-
}
|
|
18
|
-
const projectNameValidation = (0, _utils2.validateProjectName)(projectName);
|
|
19
|
-
if (!projectNameValidation.isValid) {
|
|
20
|
-
throw new Error(projectNameValidation.errorMessage);
|
|
21
|
-
}
|
|
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");
|
|
26
|
-
}
|
|
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`));
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(_chalk.default.red(`\n${error.message}`));
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AuthCredentials, FileSystemTree } from "../init/types";
|
|
2
|
-
export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
|
|
3
|
-
export declare function deployProject(projectName: string, auth: AuthCredentials): Promise<boolean>;
|
|
4
|
-
export declare const validateProjectName: (projectName: string) => {
|
|
5
|
-
isValid: boolean;
|
|
6
|
-
errorMessage?: string;
|
|
7
|
-
};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertProjectToCodeTree = convertProjectToCodeTree;
|
|
7
|
-
exports.deployProject = deployProject;
|
|
8
|
-
exports.validateProjectName = void 0;
|
|
9
|
-
var fs = _interopRequireWildcard(require("fs"));
|
|
10
|
-
var path = _interopRequireWildcard(require("path"));
|
|
11
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
|
-
var _minimatch = _interopRequireDefault(require("minimatch"));
|
|
13
|
-
var _zod = require("zod");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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); }
|
|
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; }
|
|
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) {
|
|
25
|
-
const relativePath = path.relative(projectPath, filePath);
|
|
26
|
-
if (relativePath.startsWith("node_modules")) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
for (const pattern of patterns) {
|
|
30
|
-
if (!pattern || pattern.startsWith("#")) continue;
|
|
31
|
-
if (pattern.startsWith("!")) {
|
|
32
|
-
if ((0, _minimatch.default)(relativePath, pattern.substring(1))) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
} else if ((0, _minimatch.default)(relativePath, pattern)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
42
|
-
const results = [];
|
|
43
|
-
function traverseDirectory(dirPath) {
|
|
44
|
-
try {
|
|
45
|
-
const entries = fs.readdirSync(dirPath);
|
|
46
|
-
for (const entry of entries) {
|
|
47
|
-
const fullPath = path.join(dirPath, entry);
|
|
48
|
-
if (matchesGitignorePatterns(fullPath, ignorePatterns, projectPath)) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
const stats = fs.statSync(fullPath);
|
|
53
|
-
if (stats.isDirectory()) {
|
|
54
|
-
traverseDirectory(fullPath);
|
|
55
|
-
} else if (stats.isFile()) {
|
|
56
|
-
results.push(path.relative(projectPath, fullPath));
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.log(_chalk.default.yellow(`Warning: Could not access ${fullPath}`));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.log(_chalk.default.yellow(`Warning: Could not read directory ${dirPath}`));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
traverseDirectory(projectPath);
|
|
67
|
-
return results;
|
|
68
|
-
}
|
|
69
|
-
async function convertProjectToCodeTree(projectPath) {
|
|
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
|
-
if (!gitignoreFound) {
|
|
87
|
-
console.log(_chalk.default.yellow(".gitignore file not found. Using default exclusions only."));
|
|
88
|
-
} else {
|
|
89
|
-
console.log(_chalk.default.yellow("Using standard exclusions plus .gitignore patterns."));
|
|
90
|
-
}
|
|
91
|
-
const filesToDeploy = listFilesNotIgnored(projectPath, ignorePatterns);
|
|
92
|
-
let totalSize = 0;
|
|
93
|
-
for (const file of filesToDeploy) {
|
|
94
|
-
try {
|
|
95
|
-
const stats = fs.statSync(path.join(projectPath, file));
|
|
96
|
-
totalSize += stats.size;
|
|
97
|
-
} catch (error) {}
|
|
98
|
-
}
|
|
99
|
-
console.log(_chalk.default.cyan("\nFiles to be deployed:"));
|
|
100
|
-
if (filesToDeploy.length > 100) {
|
|
101
|
-
console.log(_chalk.default.yellow(` ${filesToDeploy.length} files (too many to display)`));
|
|
102
|
-
} else {
|
|
103
|
-
const filesToDeployText = "\n " + filesToDeploy.join("\n ");
|
|
104
|
-
console.log(filesToDeployText);
|
|
105
|
-
}
|
|
106
|
-
console.log(_chalk.default.cyan(`\nSummary: ${filesToDeploy.length} files, ${formatBytes(totalSize)}`));
|
|
107
|
-
function readDirectory(dirPath) {
|
|
108
|
-
const tree = {};
|
|
109
|
-
try {
|
|
110
|
-
const entries = fs.readdirSync(dirPath);
|
|
111
|
-
for (const entry of entries) {
|
|
112
|
-
const entryPath = path.join(dirPath, entry);
|
|
113
|
-
if (matchesGitignorePatterns(entryPath, ignorePatterns, projectPath)) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
const stats = fs.statSync(entryPath);
|
|
118
|
-
if (stats.isFile()) {
|
|
119
|
-
try {
|
|
120
|
-
const content = fs.readFileSync(entryPath, "utf-8");
|
|
121
|
-
tree[entry] = {
|
|
122
|
-
file: {
|
|
123
|
-
contents: content
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.log(_chalk.default.yellow(`Warning: Could not read file ${entryPath}`));
|
|
128
|
-
}
|
|
129
|
-
} else if (stats.isDirectory()) {
|
|
130
|
-
const subTree = readDirectory(entryPath);
|
|
131
|
-
if (Object.keys(subTree).length > 0) {
|
|
132
|
-
tree[entry] = {
|
|
133
|
-
directory: subTree
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.log(_chalk.default.yellow(`Warning: Could not access ${entryPath}`));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.log(_chalk.default.yellow(`Warning: Could not read directory ${dirPath}`));
|
|
143
|
-
}
|
|
144
|
-
return tree;
|
|
145
|
-
}
|
|
146
|
-
console.log(_chalk.default.cyan("\nBuilding code tree..."));
|
|
147
|
-
const tree = readDirectory(projectPath);
|
|
148
|
-
console.log(_chalk.default.green("Code tree generation complete!"));
|
|
149
|
-
return tree;
|
|
150
|
-
}
|
|
151
|
-
async function deployProject(projectName, auth) {
|
|
152
|
-
const {
|
|
153
|
-
workspaceId,
|
|
154
|
-
apiKey
|
|
155
|
-
} = auth;
|
|
156
|
-
const baseUrl = "https://rauf-2.intuned-team-local.com";
|
|
157
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create`;
|
|
158
|
-
const headers = {
|
|
159
|
-
"x-api-key": apiKey,
|
|
160
|
-
"Content-Type": "application/json"
|
|
161
|
-
};
|
|
162
|
-
const projectPath = process.cwd();
|
|
163
|
-
const codeTree = await convertProjectToCodeTree(projectPath);
|
|
164
|
-
const deployProjectPayload = {
|
|
165
|
-
name: projectName,
|
|
166
|
-
codeTree: codeTree,
|
|
167
|
-
isCli: true,
|
|
168
|
-
language: "typescript"
|
|
169
|
-
};
|
|
170
|
-
const response = await fetch(url, {
|
|
171
|
-
headers,
|
|
172
|
-
method: "POST",
|
|
173
|
-
body: JSON.stringify(deployProjectPayload)
|
|
174
|
-
});
|
|
175
|
-
if (!response.ok) {
|
|
176
|
-
throw new Error(`Error deploying project`);
|
|
177
|
-
}
|
|
178
|
-
const data = await response.json();
|
|
179
|
-
if (response.status === 202) {
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
if (!data) {
|
|
183
|
-
throw new Error("Project not deployed");
|
|
184
|
-
}
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
const validateProjectName = projectName => {
|
|
188
|
-
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, {
|
|
189
|
-
message: "Name cannot be a UUID"
|
|
190
|
-
});
|
|
191
|
-
const validation = nameSchema.safeParse(projectName);
|
|
192
|
-
if (!validation.success) {
|
|
193
|
-
console.error(_chalk.default.red(validation.error.errors[0].message));
|
|
194
|
-
return {
|
|
195
|
-
isValid: false,
|
|
196
|
-
errorMessage: validation.error.errors[0].message
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
isValid: true
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
exports.validateProjectName = validateProjectName;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _commander = require("commander");
|
|
5
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
_dotenv.default.config({
|
|
10
|
-
path: `.env`
|
|
11
|
-
});
|
|
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
|
-
try {
|
|
14
|
-
const auth = (0, _utils.getAuthCredentials)(options);
|
|
15
|
-
const template = await (0, _utils.selectTemplate)(templateName);
|
|
16
|
-
await (0, _utils.checkEmptyDirectory)();
|
|
17
|
-
await (0, _utils.scaffoldProject)(template, auth);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error(_chalk.default.red(`\n${error.message}`));
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export declare const templateIds: string[];
|
|
2
|
-
export type TemplateId = (typeof templateIds)[number];
|
|
3
|
-
/**
|
|
4
|
-
* A simple, tree-like structure to describe the contents of a folder to be mounted.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```
|
|
8
|
-
* const tree = {
|
|
9
|
-
* myproject: {
|
|
10
|
-
* directory: {
|
|
11
|
-
* 'foo.js': {
|
|
12
|
-
* file: {
|
|
13
|
-
* contents: 'const x = 1;',
|
|
14
|
-
* },
|
|
15
|
-
* },
|
|
16
|
-
* .envrc: {
|
|
17
|
-
* file: {
|
|
18
|
-
* contents: 'ENVIRONMENT=staging'
|
|
19
|
-
* }
|
|
20
|
-
* },
|
|
21
|
-
* },
|
|
22
|
-
* },
|
|
23
|
-
* emptyFolder: {
|
|
24
|
-
* directory: {}
|
|
25
|
-
* },
|
|
26
|
-
* };
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export interface FileSystemTree {
|
|
30
|
-
[name: string]: DirectoryNode | FileNode;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Represents a directory, see {@link FileSystemTree}.
|
|
34
|
-
*/
|
|
35
|
-
export interface DirectoryNode {
|
|
36
|
-
directory: FileSystemTree;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Represents a file, see {@link FileSystemTree}.
|
|
40
|
-
*/
|
|
41
|
-
export interface FileNode {
|
|
42
|
-
file: {
|
|
43
|
-
/**
|
|
44
|
-
* The contents of the file, either as a UTF-8 string or as raw binary.
|
|
45
|
-
*/
|
|
46
|
-
contents: string | Uint8Array;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export interface AuthCredentials {
|
|
50
|
-
workspaceId: string;
|
|
51
|
-
apiKey: string;
|
|
52
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import { AuthCredentials, FileSystemTree } from "./types";
|
|
2
|
-
export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
|
|
3
|
-
export declare function checkEmptyDirectory(): Promise<void>;
|
|
4
|
-
export declare function getAuthCredentials(options: any): {
|
|
5
|
-
workspaceId: any;
|
|
6
|
-
apiKey: any;
|
|
7
|
-
};
|
|
8
|
-
export declare function selectTemplate(templateName: any): Promise<any>;
|
|
9
|
-
export declare function scaffoldProject(templateId: string, authCredentials: AuthCredentials): Promise<void>;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkEmptyDirectory = checkEmptyDirectory;
|
|
7
|
-
exports.getAuthCredentials = getAuthCredentials;
|
|
8
|
-
exports.mountFiles = mountFiles;
|
|
9
|
-
exports.scaffoldProject = scaffoldProject;
|
|
10
|
-
exports.selectTemplate = selectTemplate;
|
|
11
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
-
var _types = require("./types");
|
|
13
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
|
-
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
15
|
-
var _path = _interopRequireDefault(require("path"));
|
|
16
|
-
var _boxen = _interopRequireDefault(require("boxen"));
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
|
-
function _isDirectoryNode(node) {
|
|
21
|
-
return node.directory !== undefined;
|
|
22
|
-
}
|
|
23
|
-
function _isFileNode(node) {
|
|
24
|
-
return node.file !== undefined;
|
|
25
|
-
}
|
|
26
|
-
async function mountFiles(cwd, tree) {
|
|
27
|
-
for (const name in tree) {
|
|
28
|
-
const fullPath = _path.default.join(cwd, name);
|
|
29
|
-
const node = tree[name];
|
|
30
|
-
if (_isDirectoryNode(node)) {
|
|
31
|
-
await fs.ensureDir(fullPath);
|
|
32
|
-
await mountFiles(fullPath, node.directory);
|
|
33
|
-
} else if (_isFileNode(node)) {
|
|
34
|
-
await fs.writeFile(fullPath, node.file.contents);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function checkEmptyDirectory() {
|
|
39
|
-
const currentDir = process.cwd();
|
|
40
|
-
try {
|
|
41
|
-
const stats = await fs.stat(currentDir);
|
|
42
|
-
if (!stats.isDirectory()) {
|
|
43
|
-
throw new Error("The current path is not a directory.");
|
|
44
|
-
}
|
|
45
|
-
const files = await fs.readdir(currentDir);
|
|
46
|
-
const significantFiles = files.filter(file => ![".git", ".DS_Store", "Thumbs.db", ".gitkeep"].includes(file));
|
|
47
|
-
if (significantFiles.length) {
|
|
48
|
-
throw new Error("The current directory is not empty.");
|
|
49
|
-
}
|
|
50
|
-
} catch (error) {
|
|
51
|
-
if (error.code === "ENOENT") {
|
|
52
|
-
throw new Error("The specified directory does not exist.");
|
|
53
|
-
}
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function getAuthCredentials(options) {
|
|
58
|
-
const workspaceId = options.workspaceId || process.env.INTUNED_WORKSPACE_ID;
|
|
59
|
-
const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
|
|
60
|
-
const missingAuth = [];
|
|
61
|
-
if (!workspaceId) {
|
|
62
|
-
missingAuth.push({
|
|
63
|
-
type: "input",
|
|
64
|
-
name: "workspaceId",
|
|
65
|
-
message: "Enter your Intuned workspace ID:",
|
|
66
|
-
validate: input => input.trim() !== "" ? true : "Workspace ID is required"
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (!apiKey) {
|
|
70
|
-
missingAuth.push({
|
|
71
|
-
type: "password",
|
|
72
|
-
name: "apiKey",
|
|
73
|
-
message: "Enter your Intuned API key:",
|
|
74
|
-
mask: "*",
|
|
75
|
-
validate: input => input.trim() !== "" ? true : "API key is required"
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (missingAuth.length) {
|
|
79
|
-
throw new Error("Authentication details are required. Please provide them via command line options or environment variables.");
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
workspaceId,
|
|
83
|
-
apiKey
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
async function selectTemplate(templateName) {
|
|
87
|
-
if (templateName) {
|
|
88
|
-
const validTemplate = _types.templateIds.find(t => t === templateName);
|
|
89
|
-
if (!validTemplate) {
|
|
90
|
-
console.log(_chalk.default.yellow(`\nā ļø Template "${templateName}" not found.`));
|
|
91
|
-
} else {
|
|
92
|
-
return templateName;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
console.log(_chalk.default.yellow("\nš Select a Template"));
|
|
96
|
-
const {
|
|
97
|
-
template
|
|
98
|
-
} = await _inquirer.default.prompt([{
|
|
99
|
-
type: "list",
|
|
100
|
-
name: "template",
|
|
101
|
-
message: "Which template would you like to use?",
|
|
102
|
-
choices: _types.templateIds,
|
|
103
|
-
loop: false
|
|
104
|
-
}]);
|
|
105
|
-
return template;
|
|
106
|
-
}
|
|
107
|
-
async function scaffoldProject(templateId, authCredentials) {
|
|
108
|
-
const cwd = process.cwd();
|
|
109
|
-
console.log(_chalk.default.cyan(`\nš Initializing ${_chalk.default.bold(templateId)} project...\n`));
|
|
110
|
-
console.log(_chalk.default.cyan("š¦ Fetching template..."));
|
|
111
|
-
const template = await fetchProjectTemplate(templateId, authCredentials);
|
|
112
|
-
console.log(_chalk.default.green(`ā Template "${template}" fetched successfully!`));
|
|
113
|
-
console.log(_chalk.default.cyan("šØ Creating project files..."));
|
|
114
|
-
const codeTree = template;
|
|
115
|
-
await mountFiles(cwd, codeTree);
|
|
116
|
-
console.log(_chalk.default.green("ā Project files created!"));
|
|
117
|
-
console.log((0, _boxen.default)(_chalk.default.green(`ā
Project initialized successfully!`) + `\n\n${_chalk.default.cyan("Project details:")}` + `\n⢠Template: ${_chalk.default.bold(template)}` + `\n⢠Directory: ${_chalk.default.bold(process.cwd())}` + `\n⢠Workspace ID: ${_chalk.default.bold(authCredentials.workspaceId.substring(0, 5) + "...")}` + `\n\n${_chalk.default.cyan("Next steps:")}` + `\n1. ${_chalk.default.bold("cd")} into your project directory (if not already there)` + `\n2. Run ${_chalk.default.bold("npm install")} to install dependencies` + `\n3. Run ${_chalk.default.bold("npm start")} to start the development server`, {
|
|
118
|
-
padding: 1,
|
|
119
|
-
margin: 1,
|
|
120
|
-
borderStyle: "round",
|
|
121
|
-
borderColor: "green"
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
async function fetchProjectTemplate(templateId, authCredentials) {
|
|
125
|
-
const {
|
|
126
|
-
workspaceId,
|
|
127
|
-
apiKey
|
|
128
|
-
} = authCredentials;
|
|
129
|
-
const baseUrl = "https://rauf-2.intuned-team-local.com";
|
|
130
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/templates/${templateId}`;
|
|
131
|
-
const headers = {
|
|
132
|
-
"x-api-key": apiKey
|
|
133
|
-
};
|
|
134
|
-
const response = await fetch(url, {
|
|
135
|
-
headers
|
|
136
|
-
});
|
|
137
|
-
if (!response.ok) {
|
|
138
|
-
throw new Error(`Error fetching template: ${response.statusText} (${response.status})`);
|
|
139
|
-
}
|
|
140
|
-
const data = await response.json();
|
|
141
|
-
if (!data) {
|
|
142
|
-
throw new Error("Template not found");
|
|
143
|
-
}
|
|
144
|
-
return data.template;
|
|
145
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.executeCLI = executeCLI;
|
|
8
|
-
var _commander = require("commander");
|
|
9
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
-
var _runApi = require("../../common/runApi");
|
|
12
|
-
var _tsNodeImport = require("../common/tsNodeImport");
|
|
13
|
-
var _utils = require("./utils");
|
|
14
|
-
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
15
|
-
var _nanoid = require("nanoid");
|
|
16
|
-
var _enums = require("../../runtime/enums");
|
|
17
|
-
var _Logger = require("../../common/Logger");
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
async function executeCLI(apiName, inputData, options) {
|
|
22
|
-
const runApiResult = await (0, _runApi.runApi)({
|
|
23
|
-
automationFunction: {
|
|
24
|
-
name: `api/${apiName}`,
|
|
25
|
-
params: inputData
|
|
26
|
-
},
|
|
27
|
-
runOptions: {
|
|
28
|
-
environment: "standalone"
|
|
29
|
-
},
|
|
30
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
31
|
-
});
|
|
32
|
-
if (runApiResult.isErr()) {
|
|
33
|
-
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
34
|
-
throw runApiResult.error.error;
|
|
35
|
-
}
|
|
36
|
-
console.error(runApiResult.error);
|
|
37
|
-
throw new Error("An error occurred while running the API");
|
|
38
|
-
}
|
|
39
|
-
const {
|
|
40
|
-
result,
|
|
41
|
-
extendedPayloads: payloadToAppend
|
|
42
|
-
} = runApiResult.value;
|
|
43
|
-
const isResponseObject = typeof result === "object" && result !== null;
|
|
44
|
-
const hasMoreThank5Keys = isResponseObject && Object.keys(result).length > 5;
|
|
45
|
-
const hasNestedObjects = isResponseObject && Object.values(result).some(value => typeof value === "object");
|
|
46
|
-
const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
|
|
47
|
-
const resultsDir = "/tmp/run-results";
|
|
48
|
-
if (options.outputFileId && shouldWriteToFile) {
|
|
49
|
-
_Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
|
|
50
|
-
fs.ensureDirSync(resultsDir);
|
|
51
|
-
const path = `${resultsDir}/${options.outputFileId}.json`;
|
|
52
|
-
await fs.writeJson(path, result, {
|
|
53
|
-
spaces: 2
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
console.log("result:", result);
|
|
57
|
-
}
|
|
58
|
-
const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
|
|
59
|
-
if (hasPayloadToAppend && options.outputFileId) {
|
|
60
|
-
_Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
|
|
61
|
-
fs.ensureDirSync(resultsDir);
|
|
62
|
-
const path = `${resultsDir}/${options.outputFileId}-payloads-to-append.json`;
|
|
63
|
-
await fs.writeJson(path, payloadToAppend, {
|
|
64
|
-
spaces: 2
|
|
65
|
-
});
|
|
66
|
-
} else if (hasPayloadToAppend) {
|
|
67
|
-
_Logger.logger.info("payload to append:", payloadToAppend);
|
|
68
|
-
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
_commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-p, --parameters-file <file>", "JSON file containing API parameters").option("-o, --output-file <file>", "File to write the API output to").action(async (apiName, options) => {
|
|
72
|
-
const inputData = await (0, _utils.loadParameters)(options.parametersFile);
|
|
73
|
-
try {
|
|
74
|
-
await (0, _asyncLocalStorage.runWithContext)({
|
|
75
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
76
|
-
extendedPayloads: [],
|
|
77
|
-
runId: (0, _nanoid.nanoid)()
|
|
78
|
-
}, () => executeCLI(apiName, inputData, options));
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error(_chalk.default.red(`\nError: ${error.message}`));
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
_commander.program.parse(process.argv);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function loadParameters(parametersFile: string): Promise<object | null>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadParameters = loadParameters;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
|
-
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); }
|
|
10
|
-
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; }
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
async function loadParameters(parametersFile) {
|
|
13
|
-
if (!parametersFile) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const filePath = _path.default.resolve(process.cwd(), parametersFile);
|
|
18
|
-
await fs.access(filePath);
|
|
19
|
-
let inputData = null;
|
|
20
|
-
if (parametersFile) {
|
|
21
|
-
inputData = await fs.readJSON(parametersFile);
|
|
22
|
-
} else {
|
|
23
|
-
inputData = {};
|
|
24
|
-
}
|
|
25
|
-
return inputData;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
if (error.code === "ENOENT") {
|
|
28
|
-
throw new Error(`Parameters file not found: ${parametersFile}`);
|
|
29
|
-
} else if (error instanceof SyntaxError) {
|
|
30
|
-
throw new Error(`Invalid JSON in parameters file: ${error.message}`);
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`Error reading parameters file: ${error.message}`);
|
|
33
|
-
}
|
|
34
|
-
}
|