@caleuche/cli 0.2.1 → 0.2.3

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,17 @@
1
1
  # @caleuche/cli
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 0d6214d: Making batch output path relative. Fixing variant references.
8
+
9
+ ## 0.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - e4e7ca9: Fixing issue with batch compilation.
14
+
3
15
  ## 0.2.1
4
16
 
5
17
  ### Patch Changes
package/dist/batch.js CHANGED
@@ -7,6 +7,7 @@ exports.batchCompile = batchCompile;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const utils_1 = require("./utils");
9
9
  const common_1 = require("./common");
10
+ const path_1 = __importDefault(require("path"));
10
11
  function loadVariantDefinition(variant) {
11
12
  if ((0, utils_1.isVariantDefinition)(variant)) {
12
13
  return variant;
@@ -36,21 +37,21 @@ function loadVariantDefinitions(variants) {
36
37
  return definitions;
37
38
  }
38
39
  function resolveVariantDefinition(variant, variantRegistry) {
39
- if ((0, utils_1.isVariantPath)(variant)) {
40
- const v = (0, utils_1.parse)(variant);
40
+ if ((0, utils_1.isVariantPath)(variant.data)) {
41
+ const v = (0, utils_1.parse)(variant.data);
41
42
  if (!v) {
42
43
  console.error(`Failed to parse variant at path: ${variant}`);
43
44
  return null;
44
45
  }
45
46
  return v;
46
47
  }
47
- else if ((0, utils_1.isVariantDefinition)(variant)) {
48
- return variant;
48
+ else if ((0, utils_1.isVariantDefinition)(variant.data)) {
49
+ return variant.data;
49
50
  }
50
- else if ((0, utils_1.isVariantReference)(variant)) {
51
- const v = variantRegistry[variant];
51
+ else if ((0, utils_1.isVariantReference)(variant.data)) {
52
+ const v = variantRegistry[variant.data];
52
53
  if (!v) {
53
- console.error(`Variant reference "${variant}" not found in registry.`);
54
+ console.error(`Variant reference "${variant.data}" not found in registry.`);
54
55
  return null;
55
56
  }
56
57
  return v;
@@ -73,21 +74,26 @@ function batchCompile(batchFile) {
73
74
  process.exit(1);
74
75
  }
75
76
  const variants = loadVariantDefinitions(bachDefinition.variants);
77
+ console.log(`Loaded ${Object.keys(variants || {}).length} variant definitions from batch file.`);
76
78
  if (!variants) {
77
79
  process.exit(1);
78
80
  }
79
81
  const samples = bachDefinition.samples;
80
82
  for (const sampleDefinition of samples) {
81
- const sample = (0, common_1.resolveAndParseSample)(sampleDefinition.templatePath);
83
+ console.log(`Processing sample: ${sampleDefinition.templatePath}`);
84
+ const templatePath = path_1.default.join(path_1.default.dirname(batchFile), sampleDefinition.templatePath);
85
+ const sample = (0, common_1.resolveAndParseSample)(templatePath);
82
86
  if (!sample) {
83
87
  process.exit(1);
84
88
  }
85
89
  for (const variant of sampleDefinition.variants) {
90
+ console.log("Processing variant...");
86
91
  const resolvedVariant = resolveVariantDefinition(variant, variants);
87
92
  if (!resolvedVariant) {
88
93
  process.exit(1);
89
94
  }
90
- if (!(0, common_1.compileAndWriteOutput)(sample, resolvedVariant, variant.output, {
95
+ const effectiveOutputPath = path_1.default.join(path_1.default.dirname(batchFile), variant.output);
96
+ if (!(0, common_1.compileAndWriteOutput)(sample, resolvedVariant, effectiveOutputPath, {
91
97
  project: true,
92
98
  })) {
93
99
  console.error(`Sample: ${sampleDefinition.templatePath}, Variant: ${JSON.stringify(variant)}`);
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const commander_1 = require("commander");
5
5
  const compile_1 = require("./compile");
6
+ const batch_1 = require("./batch");
6
7
  const package_json_1 = require("../package.json");
7
8
  commander_1.program
8
9
  .name("@caleuche/cli")
@@ -12,7 +13,5 @@ commander_1.program
12
13
  .command("compile <sample-directory> <data-file> <output-directory>")
13
14
  .option("-p, --project", "Generate project file")
14
15
  .action(compile_1.compile);
15
- commander_1.program.command("batch <batch-file>").action((batchFile) => {
16
- console.log(`Batch compiling samples from ${batchFile}`);
17
- });
16
+ commander_1.program.command("batch <batch-file>").action(batch_1.batchCompile);
18
17
  commander_1.program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caleuche/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "che": "dist/index.js"
package/src/batch.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  parse,
7
7
  } from "./utils";
8
8
  import { compileAndWriteOutput, resolveAndParseSample } from "./common";
9
+ import path from "path";
9
10
 
10
11
  function loadVariantDefinition(
11
12
  variant: SampleVariantDefinition | SampleVariantPath,
@@ -42,22 +43,24 @@ function loadVariantDefinitions(
42
43
  }
43
44
 
44
45
  function resolveVariantDefinition(
45
- variant: SampleVariant,
46
+ variant: SampleVariantConfig,
46
47
  variantRegistry: Record<string, SampleVariantDefinition>,
47
48
  ): SampleVariantDefinition | null {
48
- if (isVariantPath(variant)) {
49
- const v = parse<SampleVariantDefinition>(variant);
49
+ if (isVariantPath(variant.data)) {
50
+ const v = parse<SampleVariantDefinition>(variant.data);
50
51
  if (!v) {
51
52
  console.error(`Failed to parse variant at path: ${variant}`);
52
53
  return null;
53
54
  }
54
55
  return v;
55
- } else if (isVariantDefinition(variant)) {
56
- return variant;
57
- } else if (isVariantReference(variant)) {
58
- const v = variantRegistry[variant];
56
+ } else if (isVariantDefinition(variant.data)) {
57
+ return variant.data;
58
+ } else if (isVariantReference(variant.data)) {
59
+ const v = variantRegistry[variant.data];
59
60
  if (!v) {
60
- console.error(`Variant reference "${variant}" not found in registry.`);
61
+ console.error(
62
+ `Variant reference "${variant.data}" not found in registry.`,
63
+ );
61
64
  return null;
62
65
  }
63
66
  return v;
@@ -81,24 +84,38 @@ export function batchCompile(batchFile: string) {
81
84
  process.exit(1);
82
85
  }
83
86
  const variants = loadVariantDefinitions(bachDefinition.variants);
87
+ console.log(
88
+ `Loaded ${Object.keys(variants || {}).length} variant definitions from batch file.`,
89
+ );
84
90
  if (!variants) {
85
91
  process.exit(1);
86
92
  }
87
93
  const samples = bachDefinition.samples;
88
94
  for (const sampleDefinition of samples) {
89
- const sample = resolveAndParseSample(sampleDefinition.templatePath);
95
+ console.log(`Processing sample: ${sampleDefinition.templatePath}`);
96
+ const templatePath = path.join(
97
+ path.dirname(batchFile),
98
+ sampleDefinition.templatePath,
99
+ );
100
+ const sample = resolveAndParseSample(templatePath);
90
101
  if (!sample) {
91
102
  process.exit(1);
92
103
  }
93
104
 
94
105
  for (const variant of sampleDefinition.variants) {
106
+ console.log("Processing variant...");
95
107
  const resolvedVariant = resolveVariantDefinition(variant, variants);
96
108
  if (!resolvedVariant) {
97
109
  process.exit(1);
98
110
  }
99
111
 
112
+ const effectiveOutputPath = path.join(
113
+ path.dirname(batchFile),
114
+ variant.output,
115
+ );
116
+
100
117
  if (
101
- !compileAndWriteOutput(sample, resolvedVariant, variant.output, {
118
+ !compileAndWriteOutput(sample, resolvedVariant, effectiveOutputPath, {
102
119
  project: true,
103
120
  })
104
121
  ) {
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { program } from "commander";
4
4
  import { compile } from "./compile";
5
+ import { batchCompile } from "./batch";
5
6
  import { version } from "../package.json";
6
7
 
7
8
  program
@@ -14,8 +15,6 @@ program
14
15
  .option("-p, --project", "Generate project file")
15
16
  .action(compile);
16
17
 
17
- program.command("batch <batch-file>").action((batchFile) => {
18
- console.log(`Batch compiling samples from ${batchFile}`);
19
- });
18
+ program.command("batch <batch-file>").action(batchCompile);
20
19
 
21
20
  program.parse();