@interopio/iocd-cli 0.0.59 → 0.0.61

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,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.checkForUpdates = checkForUpdates;
37
+ const colors_1 = require("./colors");
38
+ const logger_1 = require("./logger");
39
+ const pacakge_json_helper_1 = require("./pacakge.json.helper");
40
+ const clack = __importStar(require("@clack/prompts"));
41
+ const logger = logger_1.Logger.getInstance("version-check");
42
+ /**
43
+ * Compare two semver version strings
44
+ * Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2
45
+ */
46
+ function compareVersions(v1, v2) {
47
+ const parts1 = v1.replace(/^v/, "").split(".").map(Number);
48
+ const parts2 = v2.replace(/^v/, "").split(".").map(Number);
49
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
50
+ const p1 = parts1[i] || 0;
51
+ const p2 = parts2[i] || 0;
52
+ if (p1 < p2)
53
+ return -1;
54
+ if (p1 > p2)
55
+ return 1;
56
+ }
57
+ return 0;
58
+ }
59
+ /**
60
+ * Check if a newer version of the CLI is available on npm
61
+ * Logs a warning message if an update is available
62
+ */
63
+ async function checkForUpdates() {
64
+ try {
65
+ const packageName = "@interopio/iocd-cli";
66
+ const currentVersion = pacakge_json_helper_1.PackageJSONHelper.getCliPackageJson().version;
67
+ logger.debug(`Checking for updates... Current version: ${currentVersion}`);
68
+ // Fetch latest version from npm registry with a short timeout
69
+ const controller = new AbortController();
70
+ const timeoutId = setTimeout(() => controller.abort(), 3000); // 3 second timeout
71
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
72
+ signal: controller.signal,
73
+ headers: {
74
+ Accept: "application/json",
75
+ },
76
+ });
77
+ clearTimeout(timeoutId);
78
+ if (!response.ok) {
79
+ logger.debug(`Failed to fetch npm registry: ${response.status}`);
80
+ return;
81
+ }
82
+ const data = (await response.json());
83
+ const latestVersion = data.version;
84
+ logger.debug(`Latest version on npm: ${latestVersion}`);
85
+ if (compareVersions(currentVersion, latestVersion) < 0) {
86
+ // Current version is older than latest
87
+ clack.log.warn((0, colors_1.yellow)(`A new version of ${packageName} is available: ${latestVersion} (current: ${currentVersion}). Run npm i ${packageName}@latest to update.`));
88
+ logger.debug("A new version of ${packageName} is available: ${latestVersion} (current: ${currentVersion})");
89
+ }
90
+ }
91
+ catch (error) {
92
+ // Silently fail - don't block CLI execution for version check failures
93
+ if (error instanceof Error && error.name === "AbortError") {
94
+ logger.debug("Version check timed out");
95
+ }
96
+ else {
97
+ logger.debug(`Version check failed: ${error instanceof Error ? error.message : "Unknown error"}`);
98
+ }
99
+ }
100
+ }
101
+ //# sourceMappingURL=version-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-check.js","sourceRoot":"","sources":["../../src/utils/version-check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,0CAsDC;AAlFD,qCAAkC;AAClC,qCAAkC;AAClC,+DAA0D;AAC1D,sDAAwC;AAExC,MAAM,MAAM,GAAG,eAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAEnD;;;GAGG;AACH,SAAS,eAAe,CAAC,EAAU,EAAE,EAAU;IAC7C,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,qBAAqB,CAAC;QAC1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AAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC1D,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CACV,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACpF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/iocd-cli",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "CLI tool for setting up, building and packaging io.Connect Desktop platforms",
5
5
  "engines": {
6
6
  "node": ">=22.0.0",
@@ -15,12 +15,8 @@
15
15
  "generate-schema": "node ./scripts/generate-schema.js",
16
16
  "copy-assets": "node ./scripts/copy-assets.js",
17
17
  "dev": "tsc --watch",
18
- "test": "NODE_OPTIONS='--no-experimental-webstorage' jest",
19
- "test:watch": "NODE_OPTIONS='--no-experimental-webstorage' jest --watch",
20
- "test:unit": "NODE_OPTIONS='--no-experimental-webstorage' jest --selectProjects=unit",
21
- "test:e2e": "npm run build && NODE_OPTIONS='--no-experimental-webstorage' jest --selectProjects=e2e",
22
- "test:e2e:verbose": "npm run build && NODE_OPTIONS='--no-experimental-webstorage' jest --selectProjects=e2e --verbose",
23
- "test:all": "npm run test:unit && npm run test:e2e",
18
+ "test": "cross-env NODE_OPTIONS=--no-experimental-webstorage jest",
19
+ "test:watch": "cross-env NODE_OPTIONS=--no-experimental-webstorage jest --watch",
24
20
  "lint": "eslint src --ext .ts",
25
21
  "lint:fix": "eslint src --ext .ts --fix",
26
22
  "format": "prettier --write src/**/*.ts*",
@@ -45,7 +41,8 @@
45
41
  "dist",
46
42
  "scripts",
47
43
  "tools",
48
- "README.md"
44
+ "README.md",
45
+ "changelog.md"
49
46
  ],
50
47
  "dependencies": {
51
48
  "@clack/prompts": "^0.7.0",
@@ -70,10 +67,12 @@
70
67
  "@types/node": "^20.8.0",
71
68
  "@typescript-eslint/eslint-plugin": "^8.47.0",
72
69
  "@typescript-eslint/parser": "^8.47.0",
70
+ "cross-env": "^10.1.0",
73
71
  "eslint": "^8.50.0",
74
72
  "eslint-config-prettier": "^9.0.0",
75
73
  "eslint-plugin-prettier": "^5.0.0",
76
74
  "jest": "^29.7.0",
75
+ "jest-junit": "^16.0.0",
77
76
  "prettier": "^3.0.3",
78
77
  "ts-jest": "^29.1.1",
79
78
  "typescript": "^5.2.2",
@@ -14,9 +14,33 @@ if (!fs.existsSync(schemaDir)) {
14
14
  fs.mkdirSync(schemaDir, { recursive: true });
15
15
  }
16
16
 
17
+ /**
18
+ * Recursively remove all "required" arrays from a schema object.
19
+ * This makes all properties optional for user input.
20
+ */
21
+ function removeRequiredRecursively(obj) {
22
+ if (obj === null || typeof obj !== 'object') {
23
+ return obj;
24
+ }
25
+
26
+ if (Array.isArray(obj)) {
27
+ return obj.map(removeRequiredRecursively);
28
+ }
29
+
30
+ const result = {};
31
+ for (const [key, value] of Object.entries(obj)) {
32
+ // Skip "required" arrays
33
+ if (key === 'required' && Array.isArray(value)) {
34
+ continue;
35
+ }
36
+ result[key] = removeRequiredRecursively(value);
37
+ }
38
+ return result;
39
+ }
40
+
17
41
  try {
18
- // Generate schema using typescript-json-schema
19
- // Point directly to the source file to avoid compilation issues
42
+ // Generate schema using typescript-json-schema from CliConfig
43
+ // Use --required to get full schema structure, then post-process to remove required arrays
20
44
  execSync(
21
45
  `npx typescript-json-schema ./src/services/config/cli.config.ts CliConfig --required --noExtraProps --out ${schemaFile}`,
22
46
  {
@@ -28,18 +52,28 @@ try {
28
52
  // Read the generated schema
29
53
  const schema = JSON.parse(fs.readFileSync(schemaFile, 'utf8'));
30
54
 
55
+ // Remove all "required" arrays recursively to make all properties optional
56
+ const schemaWithoutRequired = removeRequiredRecursively(schema);
57
+
31
58
  // Add metadata at the beginning, preserving proper order
32
59
  const enhancedSchema = {
33
60
  "$schema": "http://json-schema.org/draft-07/schema#",
34
61
  "$id": "https://unpkg.com/@interopio/iocd-cli/schemas/iocd.cli.config.schema.json",
35
62
  "title": "io.Connect Desktop CLI Configuration",
36
- "description": "Configuration schema for io.Connect Desktop CLI projects",
37
- "additionalProperties": schema.additionalProperties,
38
- "properties": schema.properties,
39
- "required": schema.required,
40
- "type": schema.type || "object"
63
+ "description": "Configuration schema for io.Connect Desktop CLI projects. All properties are optional - the CLI provides sensible defaults.",
64
+ "additionalProperties": schemaWithoutRequired.additionalProperties,
65
+ "properties": schemaWithoutRequired.properties,
66
+ "definitions": schemaWithoutRequired.definitions,
67
+ "type": schemaWithoutRequired.type || "object"
41
68
  };
42
69
 
70
+ // Remove undefined keys
71
+ Object.keys(enhancedSchema).forEach(key => {
72
+ if (enhancedSchema[key] === undefined) {
73
+ delete enhancedSchema[key];
74
+ }
75
+ });
76
+
43
77
  // Write back the updated schema
44
78
  fs.writeFileSync(schemaFile, JSON.stringify(enhancedSchema, null, 2));
45
79