@caleuche/cli 0.4.1 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @caleuche/cli
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8b3f4d5: Add support for sample tags
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [8b3f4d5]
12
+ - @caleuche/core@0.4.0
13
+
3
14
  ## 0.4.1
4
15
 
5
16
  ### Patch Changes
package/dist/batch.js CHANGED
@@ -97,6 +97,9 @@ function batchCompile(batchFile, options) {
97
97
  if (!resolvedVariant) {
98
98
  process.exit(1);
99
99
  }
100
+ if (variant.tags) {
101
+ sample.tags = variant.tags;
102
+ }
100
103
  const effectiveOutputPath = path_1.default.join(options?.outputDir || workingDirectory, variant.output);
101
104
  if (!(0, common_1.compileAndWriteOutput)(sample, resolvedVariant.properties, effectiveOutputPath, {
102
105
  project: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caleuche/cli",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "che": "dist/index.js"
@@ -19,7 +19,7 @@
19
19
  "license": "MIT",
20
20
  "description": "Caleuche CLI",
21
21
  "dependencies": {
22
- "@caleuche/core": "^0.3.0",
22
+ "@caleuche/core": "^0.4.0",
23
23
  "commander": "^14.0.0",
24
24
  "yaml": "^2.8.0"
25
25
  },
package/src/batch.ts CHANGED
@@ -128,6 +128,10 @@ export function batchCompile(
128
128
  process.exit(1);
129
129
  }
130
130
 
131
+ if (variant.tags) {
132
+ sample.tags = variant.tags;
133
+ }
134
+
131
135
  const effectiveOutputPath = path.join(
132
136
  options?.outputDir || workingDirectory,
133
137
  variant.output,
package/src/interfaces.ts CHANGED
@@ -21,6 +21,7 @@ type SampleVariantInput =
21
21
  interface SampleVariantConfig {
22
22
  output: string;
23
23
  input: SampleVariantInput | string;
24
+ tags?: Record<string, any>;
24
25
  }
25
26
 
26
27
  interface SampleDefinition {
package/test/bach.test.ts CHANGED
@@ -352,4 +352,54 @@ describe("batchCompile", () => {
352
352
  "console.log('2');",
353
353
  );
354
354
  });
355
+
356
+ it("should write sample tags file if defined", () => {
357
+ mockCompileSample.mockReturnValue({
358
+ items: [
359
+ { fileName: "file1.js", content: "console.log('1');" },
360
+ { fileName: "tags.yaml", content: "tag1: value1\ntag2: value2" }
361
+ ],
362
+ });
363
+ const batchFilePath = getPath("batch.yaml");
364
+ const batchFileContent = multiline`
365
+ variants:
366
+ - name: foo
367
+ input:
368
+ type: object
369
+ properties:
370
+ var2: value
371
+ samples:
372
+ - templatePath: sample.yaml
373
+ variants:
374
+ - output: out
375
+ input: foo
376
+ tags:
377
+ tag1: value1
378
+ tag2: value2
379
+ `;
380
+ fs.writeFileSync(batchFilePath, batchFileContent);
381
+ const sampleFilePath = getPath("sample.yaml");
382
+ const sampleContent = multiline`
383
+ template: sample.js.template
384
+ type: javascript
385
+ dependencies:
386
+ input:
387
+ - name: var
388
+ type: string
389
+ required: true
390
+ `;
391
+ fs.writeFileSync(sampleFilePath, sampleContent);
392
+ batchCompile(batchFilePath, {});
393
+ expect(fs.existsSync(getPath("out/file1.js"))).toBe(true);
394
+ expect(fs.readFileSync(getPath("out/file1.js"), "utf-8")).toBe(
395
+ "console.log('1');",
396
+ );
397
+ expect(fs.existsSync(getPath("out/tags.yaml"))).toBe(true);
398
+ expect(fs.readFileSync(getPath("out/tags.yaml"), "utf-8")).toBe(
399
+ multiline`
400
+ tag1: value1
401
+ tag2: value2
402
+ `,
403
+ );
404
+ });
355
405
  });