@comet/cli 8.0.0-beta.4 → 8.0.0-beta.6

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.
@@ -0,0 +1,35 @@
1
+ export interface BlockMeta {
2
+ name: string;
3
+ fields: BlockMetaField[];
4
+ inputFields: BlockMetaField[];
5
+ }
6
+ export type BlockMetaField = {
7
+ name: string;
8
+ kind: "String" | "Number" | "Boolean" | "Json";
9
+ nullable: boolean;
10
+ array?: boolean;
11
+ } | {
12
+ name: string;
13
+ kind: "Enum";
14
+ nullable: boolean;
15
+ enum: string[];
16
+ } | {
17
+ name: string;
18
+ kind: "Block";
19
+ nullable: boolean;
20
+ block: string;
21
+ } | {
22
+ name: string;
23
+ kind: "OneOfBlocks";
24
+ nullable: boolean;
25
+ blocks: Record<string, string>;
26
+ } | {
27
+ name: string;
28
+ kind: "NestedObject" | "NestedObjectList";
29
+ nullable: boolean;
30
+ object: BlockMetaNestedObject;
31
+ };
32
+ interface BlockMetaNestedObject {
33
+ fields: BlockMetaField[];
34
+ }
35
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -120,6 +120,14 @@ function writeFieldType(field, blockNamePostfix) {
120
120
  content += "}>\n";
121
121
  }
122
122
  }
123
+ var generateAllBlockNames = function (blockMeta) {
124
+ var uniqueBlockNames = Array.from(new Set(blockMeta.map(function (block) { return block.name; }))).sort();
125
+ var content = "export type AllBlockNames =";
126
+ uniqueBlockNames.forEach(function (blockName) {
127
+ content += " | \"".concat(blockName, "\"");
128
+ });
129
+ return content;
130
+ };
123
131
  var generateBlockTypes = new commander_1.Command("generate-block-types")
124
132
  .description("generate block types from block meta")
125
133
  .option("--inputs", "include block inputs")
@@ -159,6 +167,7 @@ var generateBlockTypes = new commander_1.Command("generate-block-types")
159
167
  content += "}\n";
160
168
  });
161
169
  }
170
+ content += generateAllBlockNames(blockMeta);
162
171
  return [4 /*yield*/, (0, prettier_1.resolveConfig)(process.cwd())];
163
172
  case 2:
164
173
  prettierOptions = _a.sent();
@@ -112,7 +112,6 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
112
112
  .description("Inject site-configs into a file")
113
113
  .requiredOption("-i, --in-file <file>", "The filename of a template file to inject.")
114
114
  .requiredOption("-o, --out-file <file>", "Write the injected template to a file.")
115
- .option("-d --dotenv", "dotenv compatibility") // https://github.com/motdotla/dotenv/issues/521#issuecomment-999016064
116
115
  .option("--base64", "use base64 encoding")
117
116
  .option("-f, --site-config-file <file>", "Path to ts-file which provides a default export with (env: string) => SiteConfig[]")
118
117
  .action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
@@ -148,7 +147,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
148
147
  };
149
148
  str = str.replace(/"({{ site:\/\/configs\/.*\/.* }})"/g, "'$1'"); // convert to single quotes
150
149
  return [4 /*yield*/, replaceAsync(str, RegExp("{{ site://configs/(.*)/(.*) }}", "g"), function (substr, type, env) { return __awaiter(void 0, void 0, void 0, function () {
151
- var siteConfigs, str, ret;
150
+ var siteConfigs, ret;
152
151
  return __generator(this, function (_a) {
153
152
  switch (_a.label) {
154
153
  case 0: return [4 /*yield*/, getSiteConfigs(env)];
@@ -159,13 +158,10 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
159
158
  console.error("inject-site-configs: ERROR: type must be ".concat(Object.keys(replacerFunctions).join("|"), " (got ").concat(type, ")"));
160
159
  return [2 /*return*/, substr];
161
160
  }
162
- str = replacerFunctions[type](siteConfigs, env);
161
+ ret = JSON.stringify(replacerFunctions[type](siteConfigs, env));
163
162
  if (options.base64) {
164
- return [2 /*return*/, Buffer.from(JSON.stringify(str)).toString("base64")];
163
+ return [2 /*return*/, Buffer.from(ret).toString("base64")];
165
164
  }
166
- ret = JSON.stringify(str).replace(/\\/g, "\\\\");
167
- if (options.dotenv)
168
- return [2 /*return*/, ret.replace(/\$/g, "\\$")];
169
165
  return [2 /*return*/, ret];
170
166
  }
171
167
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/cli",
3
- "version": "8.0.0-beta.4",
3
+ "version": "8.0.0-beta.6",
4
4
  "repository": {
5
5
  "directory": "packages/cli",
6
6
  "type": "git",
@@ -22,12 +22,12 @@
22
22
  "ts-node": "^10.9.2"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^22.14.0",
25
+ "@types/node": "^22.15.34",
26
26
  "eslint": "^9.22.0",
27
27
  "npm-run-all2": "^5.0.2",
28
28
  "rimraf": "^6.0.1",
29
29
  "typescript": "^5.7.3",
30
- "@comet/eslint-config": "8.0.0-beta.4"
30
+ "@comet/eslint-config": "8.0.0-beta.6"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=22.0.0"