@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 +11 -0
- package/dist/batch.js +3 -0
- package/package.json +2 -2
- package/src/batch.ts +4 -0
- package/src/interfaces.ts +1 -0
- package/test/bach.test.ts +50 -0
package/CHANGELOG.md
CHANGED
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.
|
|
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.
|
|
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
package/src/interfaces.ts
CHANGED
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
|
});
|