@intuned/runtime-dev 1.0.6-cli.8.1.2 → 1.0.6-cli.8.1.4

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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require("../dist/commands/intuned-build-project/intuned-build-project.js");
@@ -9,3 +9,4 @@ export declare const validateIntunedProject: () => Promise<{
9
9
  isValid: boolean;
10
10
  errorMessage?: string;
11
11
  }>;
12
+ export declare const runBuild: () => Promise<boolean>;
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.convertProjectToCodeTree = convertProjectToCodeTree;
7
7
  exports.deployProject = deployProject;
8
- exports.validateProjectName = exports.validateIntunedProject = void 0;
8
+ exports.validateProjectName = exports.validateIntunedProject = exports.runBuild = void 0;
9
9
  var fs = _interopRequireWildcard(require("fs-extra"));
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");
14
16
  var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
15
17
  var _constants = require("../../common/cli/constants");
16
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -23,6 +25,7 @@ function formatBytes(bytes) {
23
25
  const i = Math.floor(Math.log(bytes) / Math.log(k));
24
26
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
25
27
  }
28
+ const execPromise = (0, _util.promisify)(_child_process.exec);
26
29
  function matchesGitignorePatterns(filePath, patterns, projectPath) {
27
30
  const relativePath = path.relative(projectPath, filePath);
28
31
  if (relativePath.startsWith("node_modules")) {
@@ -212,6 +215,27 @@ exports.validateProjectName = validateProjectName;
212
215
  const validateIntunedProject = async () => {
213
216
  const currentDirectoryToDeploy = process.cwd();
214
217
  const validationSteps = [{
218
+ name: "build",
219
+ check: async () => {
220
+ try {
221
+ const buildResult = await runBuild();
222
+ if (!buildResult) {
223
+ return {
224
+ isValid: false,
225
+ errorMessage: "Build failed"
226
+ };
227
+ }
228
+ return {
229
+ isValid: true
230
+ };
231
+ } catch (error) {
232
+ return {
233
+ isValid: false,
234
+ errorMessage: "Build failed"
235
+ };
236
+ }
237
+ }
238
+ }, {
215
239
  name: "package.json",
216
240
  check: async () => {
217
241
  try {
@@ -239,10 +263,10 @@ const validateIntunedProject = async () => {
239
263
  }
240
264
  }
241
265
  }, {
242
- name: "intuned.json",
266
+ name: "Intuned.json",
243
267
  check: async () => {
244
268
  try {
245
- const intunedJsonPath = path.join(currentDirectoryToDeploy, "intuned.json");
269
+ const intunedJsonPath = path.join(currentDirectoryToDeploy, "Intuned.json");
246
270
  await fs.exists(intunedJsonPath);
247
271
  return {
248
272
  isValid: true
@@ -298,7 +322,7 @@ const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey)
298
322
  return "not_found";
299
323
  }
300
324
  if (!response.ok) {
301
- throw new Error("Error fetching deployment status");
325
+ throw new Error("Error querying deployment status");
302
326
  }
303
327
  const data = await response.json();
304
328
  if (data.status) {
@@ -308,4 +332,24 @@ const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey)
308
332
  } catch (e) {
309
333
  throw new Error(`Error during deployment`);
310
334
  }
311
- };
335
+ };
336
+ const runBuild = async () => {
337
+ const currentProjectDirectory = process.cwd();
338
+ console.log(_chalk.default.yellow("Running build..."));
339
+ const distPath = path.join(currentProjectDirectory, "dist");
340
+ if (await fs.exists(distPath)) {
341
+ await fs.remove(distPath);
342
+ }
343
+ const buildCommand = "npx tsc";
344
+ try {
345
+ await execPromise(buildCommand, {
346
+ cwd: currentProjectDirectory
347
+ });
348
+ console.log(_chalk.default.green("🏗️ Build completed successfully"));
349
+ return true;
350
+ } catch (error) {
351
+ console.error(_chalk.default.red(`Build failed: ${error.message}`));
352
+ return false;
353
+ }
354
+ };
355
+ exports.runBuild = runBuild;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _dotenv = _interopRequireDefault(require("dotenv"));
6
+ var _utils = require("../deploy/utils");
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ _dotenv.default.config({
9
+ path: `.env`
10
+ });
11
+ _commander.program.name("intuned-build-project").description("Build your current Inuned project").action(async () => {
12
+ try {
13
+ await (0, _utils.runBuild)();
14
+ } catch (error) {
15
+ process.exit(1);
16
+ } finally {
17
+ process.exit(0);
18
+ }
19
+ });
20
+ _commander.program.parse(process.argv);
@@ -14,6 +14,9 @@ _dotenv.default.config({
14
14
  });
15
15
  _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) => {
16
16
  try {
17
+ if (!apiName) {
18
+ throw new Error("API name is required, please provide it");
19
+ }
17
20
  const inputData = await (0, _utils.loadParameters)(options.parametersFile);
18
21
  const outputFileId = options.outputFile;
19
22
  const result = await (0, _asyncLocalStorage.runWithContext)({
@@ -29,13 +32,16 @@ _commander.program.name("intuned-run").description("Run an Intuned API with para
29
32
  }
30
33
  if (!options.outputFile) {
31
34
  console.log(_chalk.default.green(`✓ API executed successfully`));
35
+ console.log(_chalk.default.green("Result:"));
36
+ console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
32
37
  return;
33
38
  }
34
39
  await (0, _utils.writeResultToFile)(outputFileId, result);
35
- process.exit(0);
36
40
  } catch (error) {
37
41
  console.error(_chalk.default.red(`\nError: ${error.message}`));
38
42
  process.exit(1);
43
+ } finally {
44
+ process.exit(0);
39
45
  }
40
46
  });
41
47
  _commander.program.parse(process.argv);
@@ -14,7 +14,7 @@ async function getAuthCredentials(options) {
14
14
  const workspaceId = options.workspaceId || (await getSettingIntunedJSON("workspaceId"));
15
15
  const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
16
16
  if (!workspaceId || !workspaceId) {
17
- throw new Error("Authentication details are required. Please provide them via command line options or environment variables.");
17
+ throw new Error("Authentication details are required. Please provide them via command line options(api key, workspace id), intuned.json(workspace id) or environment variables(api key).");
18
18
  }
19
19
  return {
20
20
  workspaceId,
@@ -22,7 +22,7 @@ async function getAuthCredentials(options) {
22
22
  };
23
23
  }
24
24
  async function getSettingIntunedJSON(key) {
25
- const intunedJsonPath = _path.default.join(process.cwd(), "intuned.json");
25
+ const intunedJsonPath = _path.default.join(process.cwd(), "Intuned.json");
26
26
  const intunedJson = await fs.readJSON(intunedJsonPath);
27
27
  if (intunedJson && intunedJson[key]) {
28
28
  return intunedJson[key];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.0.6-cli.8.1.2",
3
+ "version": "1.0.6-cli.8.1.4",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",