timonel 2.10.0 → 2.10.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.10.1](https://github.com/KenkoGeek/timonel/compare/v2.10.0...v2.10.1) (2025-09-20)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **cli:** improve version display and fallback handling ([#117](https://github.com/KenkoGeek/timonel/issues/117)) ([7ad67e2](https://github.com/KenkoGeek/timonel/commit/7ad67e23f936edcc6e9e7d886c257046ca4dccc6))
6
+ - **helm:** remove debug logs from helmChartWriter ([742e1c9](https://github.com/KenkoGeek/timonel/commit/742e1c94f2858ec1afaf90cf5f2955b692e18f6b))
7
+
1
8
  # [2.10.0](https://github.com/KenkoGeek/timonel/compare/v2.9.2...v2.10.0) (2025-09-20)
2
9
 
3
10
  ### Bug Fixes
package/dist/cli.js CHANGED
@@ -8,14 +8,53 @@ const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
9
  const UMBRELLA_CONFIG_FILE = 'umbrella.config.json';
10
10
  const UMBRELLA_FILE_NAME = 'umbrella.ts';
11
+ const PACKAGE_JSON_FILE = 'package.json';
12
+ function isValidPath(filePath, expectedFileName) {
13
+ try {
14
+ const resolvedPath = path.resolve(filePath);
15
+ const normalizedPath = path.normalize(resolvedPath);
16
+ if (normalizedPath.includes('..') || normalizedPath.includes('~')) {
17
+ return false;
18
+ }
19
+ if (!normalizedPath.endsWith(expectedFileName)) {
20
+ return false;
21
+ }
22
+ const suspiciousPatterns = ['\\', '..', '~', '$', '`', '|', '&', ';', '(', ')'];
23
+ return !suspiciousPatterns.some((pattern) => normalizedPath.includes(pattern));
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
11
29
  function getVersion() {
12
30
  try {
13
- const packagePath = path.join(__dirname, '..', 'package.json');
14
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
15
- return packageJson.version || '0.1.0';
31
+ const possiblePaths = [
32
+ path.resolve(__dirname, '..', PACKAGE_JSON_FILE),
33
+ path.resolve(__dirname, '..', '..', PACKAGE_JSON_FILE),
34
+ path.resolve(process.cwd(), PACKAGE_JSON_FILE),
35
+ path.resolve(__dirname, PACKAGE_JSON_FILE),
36
+ ];
37
+ for (const packagePath of possiblePaths) {
38
+ if (!isValidPath(packagePath, PACKAGE_JSON_FILE)) {
39
+ continue;
40
+ }
41
+ if (fs.existsSync(packagePath)) {
42
+ try {
43
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
44
+ return packageJson.version || 'unknown';
45
+ }
46
+ catch {
47
+ continue;
48
+ }
49
+ }
50
+ }
51
+ if (process.env.npm_package_version) {
52
+ return process.env.npm_package_version;
53
+ }
54
+ return 'unknown';
16
55
  }
17
56
  catch {
18
- return '0.1.0';
57
+ return 'unknown';
19
58
  }
20
59
  }
21
60
  function log(msg, silent = false) {
@@ -133,27 +133,14 @@ function getTargetDirectory(target) {
133
133
  return target === 'crds' ? 'crds' : 'templates';
134
134
  }
135
135
  function writeSingleAssetFile(outDir, targetDir, assetId, yaml) {
136
- if (assetId === 'ingress' && yaml.includes('number:')) {
137
- console.log('Writing ingress file with number fields');
138
- const numberLines = yaml.split('\n').filter((line) => line.includes('number:'));
139
- console.log('Number lines:', numberLines);
140
- }
141
136
  const filename = `${assetId}.yaml`;
142
137
  fs.mkdirSync(path.join(outDir, targetDir), { recursive: true });
143
138
  fs.writeFileSync(path.join(outDir, targetDir, filename), yaml + '\n');
144
139
  }
145
140
  function writeMultipleAssetFiles(outDir, targetDir, assetId, yaml) {
146
- if (assetId === 'ingress' && yaml.includes('number:')) {
147
- console.log('🔍 Writing ingress file (multiple) with content:');
148
- const numberLines = yaml.split('\n').filter((line) => line.includes('number:'));
149
- console.log('Number lines:', numberLines);
150
- }
151
141
  const parts = splitDocs(yaml);
152
142
  parts.forEach((doc, index) => {
153
143
  const filename = `${assetId}${parts.length > 1 ? `-${index + 1}` : ''}.yaml`;
154
- if (assetId === 'ingress' && doc.includes('number:')) {
155
- console.log(`🔍 Writing document ${index + 1} for ingress:`, doc.split('\n').filter((line) => line.includes('number:')));
156
- }
157
144
  fs.mkdirSync(path.join(outDir, targetDir), { recursive: true });
158
145
  fs.writeFileSync(path.join(outDir, targetDir, filename), doc + '\n');
159
146
  });
@@ -168,7 +168,7 @@ ${yamlContent.trim()}
168
168
  return [...this.assets];
169
169
  }
170
170
  toSynthArray() {
171
- console.log(`📦 Synthesizing chart assets for: ${this.meta.name}`);
171
+ console.log(`Synthesizing chart assets for: ${this.meta.name}`);
172
172
  const apiObjectIds = [];
173
173
  for (const child of this.chart.node.children) {
174
174
  if (child instanceof ApiObject && !child.node.id.endsWith('-placeholder')) {
@@ -184,7 +184,7 @@ ${yamlContent.trim()}
184
184
  }
185
185
  return true;
186
186
  });
187
- console.log(`📋 Found ${manifestObjs.length} manifest objects to process`);
187
+ console.log(`Found ${manifestObjs.length} manifest objects to process`);
188
188
  const enriched = manifestObjs.map((obj) => {
189
189
  if (obj && typeof obj === 'object') {
190
190
  const o = obj;
@@ -420,7 +420,7 @@ ${helper.template}
420
420
  helpersContent = generateHelpersTemplate(this.props.cloudProvider);
421
421
  }
422
422
  const synthAssets = this.toSynthArray();
423
- console.log(`📄 Generated ${synthAssets.length} assets for chart`);
423
+ console.log(`Generated ${synthAssets.length} assets for chart`);
424
424
  HelmChartWriter.write({
425
425
  outDir,
426
426
  meta: this.meta,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "timonel",
3
3
  "type": "module",
4
- "version": "2.10.0",
4
+ "version": "2.10.1",
5
5
  "description": "Timonel: programmatic Helm chart generator using cdk8s (TypeScript)",
6
6
  "bin": {
7
7
  "timonel": "dist/cli.js",
@@ -86,7 +86,7 @@
86
86
  "constructs": "^10.4.2",
87
87
  "handlebars": "^4.7.8",
88
88
  "js-yaml": "^4.1.0",
89
- "timonel": "^2.9.2",
89
+ "timonel": "^2.10.0",
90
90
  "ts-node": "^10.9.2",
91
91
  "yaml": "^2.8.1"
92
92
  },