@caleuche/cli 0.4.0 → 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 +19 -0
- package/dist/batch.js +3 -0
- package/package.json +2 -2
- package/src/batch.ts +18 -5
- package/src/index.ts +20 -5
- package/src/interfaces.ts +1 -0
- package/test/bach.test.ts +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
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
|
+
|
|
14
|
+
## 0.4.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [1dd1a48]
|
|
19
|
+
- Updated dependencies [6254997]
|
|
20
|
+
- @caleuche/core@0.3.0
|
|
21
|
+
|
|
3
22
|
## 0.4.0
|
|
4
23
|
|
|
5
24
|
### Minor 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.
|
|
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
|
@@ -80,7 +80,10 @@ function resolveVariantDefinition(
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function batchCompile(
|
|
83
|
+
export function batchCompile(
|
|
84
|
+
batchFile: string,
|
|
85
|
+
options: { outputDir?: string },
|
|
86
|
+
) {
|
|
84
87
|
if (!isFile(batchFile)) {
|
|
85
88
|
console.error(`Batch file "${batchFile}" does not exist or is not a file.`);
|
|
86
89
|
process.exit(1);
|
|
@@ -125,14 +128,24 @@ export function batchCompile(batchFile: string, options: { outputDir?: string })
|
|
|
125
128
|
process.exit(1);
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
if (variant.tags) {
|
|
132
|
+
sample.tags = variant.tags;
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
const effectiveOutputPath = path.join(
|
|
129
136
|
options?.outputDir || workingDirectory,
|
|
130
|
-
variant.output
|
|
137
|
+
variant.output,
|
|
138
|
+
);
|
|
131
139
|
|
|
132
140
|
if (
|
|
133
|
-
!compileAndWriteOutput(
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
!compileAndWriteOutput(
|
|
142
|
+
sample,
|
|
143
|
+
resolvedVariant.properties,
|
|
144
|
+
effectiveOutputPath,
|
|
145
|
+
{
|
|
146
|
+
project: true,
|
|
147
|
+
},
|
|
148
|
+
)
|
|
136
149
|
) {
|
|
137
150
|
console.error(
|
|
138
151
|
`Sample: ${sampleDefinition.templatePath}, Variant: ${JSON.stringify(variant)}`,
|
package/src/index.ts
CHANGED
|
@@ -12,16 +12,31 @@ program
|
|
|
12
12
|
|
|
13
13
|
program
|
|
14
14
|
.command("compile")
|
|
15
|
-
.argument(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
.argument(
|
|
16
|
+
"<sample-path>",
|
|
17
|
+
"Path to the sample file or the directory that containes it.",
|
|
18
|
+
)
|
|
19
|
+
.argument(
|
|
20
|
+
"<data-file>",
|
|
21
|
+
"Path to the input to be used to compile the template.",
|
|
22
|
+
)
|
|
23
|
+
.argument(
|
|
24
|
+
"<output-directory>",
|
|
25
|
+
"Directory where the compiled output will be written.",
|
|
26
|
+
)
|
|
27
|
+
.option(
|
|
28
|
+
"-p, --project",
|
|
29
|
+
"Flag to indicate whether to generate the appropriate project file along with the compiled template.",
|
|
30
|
+
)
|
|
19
31
|
.action(compile);
|
|
20
32
|
|
|
21
33
|
program
|
|
22
34
|
.command("batch")
|
|
23
35
|
.argument("<batch-file>", "Path to the batch file")
|
|
24
|
-
.option(
|
|
36
|
+
.option(
|
|
37
|
+
"-d, --output-dir <outputDir>",
|
|
38
|
+
"Output directory for compiled samples",
|
|
39
|
+
)
|
|
25
40
|
.action(batchCompile);
|
|
26
41
|
|
|
27
42
|
program.parse();
|
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
|
});
|