@orizm/cli 1.0.1 → 1.0.2

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.
Files changed (3) hide show
  1. package/bin/index.js +1 -1
  2. package/dist/cli.js +85 -109
  3. package/package.json +3 -2
package/bin/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require("../dist/cli.js");
3
+ import "../dist/cli.js";
package/dist/cli.js CHANGED
@@ -1,39 +1,15 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
1
  // src/cli.ts
26
- var import_commander6 = require("commander");
2
+ import { Command as Command6, program } from "commander";
27
3
 
28
4
  // src/cms/generate/command.ts
29
- var import_commander = require("commander");
5
+ import { Command } from "commander";
30
6
 
31
7
  // src/lib/load-config.ts
32
- var import_esbuild = __toESM(require("esbuild"));
33
- var import_config_validator = require("@orizm/common/config-validator");
34
- var v = __toESM(require("valibot"));
8
+ import esbuild from "esbuild";
9
+ import { OrizmConfigDef } from "@orizm/common/config-validator";
10
+ import * as v from "valibot";
35
11
  async function loadConfig(configFile) {
36
- const buildResult = await import_esbuild.default.build({
12
+ const buildResult = await esbuild.build({
37
13
  entryPoints: [configFile],
38
14
  bundle: true,
39
15
  write: false,
@@ -45,16 +21,16 @@ async function loadConfig(configFile) {
45
21
  buildResult.outputFiles[0].text
46
22
  )}`;
47
23
  const { default: orizmConfigRaw } = await import(moduleURL);
48
- return v.parse(import_config_validator.OrizmConfigDef, orizmConfigRaw);
24
+ return v.parse(OrizmConfigDef, orizmConfigRaw);
49
25
  }
50
26
 
51
27
  // src/lib/cli-spinner.ts
52
- var import_readline = __toESM(require("readline"));
28
+ import readline from "readline";
53
29
 
54
30
  // src/lib/cli-symbol.ts
55
- var import_cli_color = require("cli-color");
56
- var success = (0, import_cli_color.green)("\u2713");
57
- var error = (0, import_cli_color.red)("\u2717");
31
+ import cliColor from "cli-color";
32
+ var success = cliColor.green("\u2713");
33
+ var error = cliColor.red("\u2717");
58
34
 
59
35
  // src/lib/cli-cursor.ts
60
36
  function hide() {
@@ -97,8 +73,8 @@ var Spinner = class {
97
73
  clearInterval(this.timer);
98
74
  this.timer = null;
99
75
  }
100
- import_readline.default.clearLine(process.stdout, 0);
101
- import_readline.default.cursorTo(process.stdout, 0);
76
+ readline.clearLine(process.stdout, 0);
77
+ readline.cursorTo(process.stdout, 0);
102
78
  show();
103
79
  return this;
104
80
  }
@@ -110,8 +86,8 @@ var Spinner = class {
110
86
  render() {
111
87
  const frame = FRAMES[this.currentFrame];
112
88
  this.currentFrame = (this.currentFrame + 1) % FRAMES.length;
113
- import_readline.default.clearLine(process.stdout, 0);
114
- import_readline.default.cursorTo(process.stdout, 0);
89
+ readline.clearLine(process.stdout, 0);
90
+ readline.cursorTo(process.stdout, 0);
115
91
  process.stdout.write(`${frame} ${this.text}`);
116
92
  }
117
93
  };
@@ -120,8 +96,8 @@ function createSpinner() {
120
96
  }
121
97
 
122
98
  // src/lib/handle-error.ts
123
- var v2 = __toESM(require("valibot"));
124
- var cliColor = __toESM(require("cli-color"));
99
+ import * as v2 from "valibot";
100
+ import cliColor2 from "cli-color";
125
101
  function handleError(error2) {
126
102
  show();
127
103
  if (v2.isValiError(error2)) {
@@ -133,7 +109,7 @@ function handleError(error2) {
133
109
  }
134
110
  console.error();
135
111
  console.error(
136
- cliColor.red(
112
+ cliColor2.red(
137
113
  "Something went wrong. Please check the error below for more details."
138
114
  )
139
115
  );
@@ -144,14 +120,14 @@ function handleError(error2) {
144
120
  }
145
121
  function buildValiErrorMessage(e) {
146
122
  return e.issues.map((issue) => {
147
- return ` ${cliColor.red(issue.message)} (at ${cliColor.yellow(v2.getDotPath(issue))})`;
123
+ return ` ${cliColor2.red(issue.message)} (at ${cliColor2.yellow(v2.getDotPath(issue))})`;
148
124
  }).join("\n");
149
125
  }
150
126
 
151
127
  // src/cms/generate/generator.ts
152
- var import_promises = require("fs/promises");
153
- var import_path = __toESM(require("path"));
154
- var import_handlebars = __toESM(require("handlebars"));
128
+ import { mkdir, writeFile } from "fs/promises";
129
+ import path from "path";
130
+ import Handlebars from "handlebars";
155
131
 
156
132
  // src/cms/templates/types.ts.hbr
157
133
  var types_ts_default = '// This file was automatically generated and should not be edited.\n\nimport { FormValidationRules, StorageItemType } from "@orizm/common";\n\n// Utilities\ntype _ModuleRef<T> = T & _ModuleDescriptor;\ntype _ModuleDescriptor = {\n isModule: true;\n};\ntype _ArrayModuleRef<T> = T & _ArrayModuleDescriptor;\ntype _ArrayModuleDescriptor = {\n isModuleArray: true;\n};\n\n// Tables\n{{#each tables}}\nexport type {{toCodeTypeName this.name}} = {\n id: string;\n createdAt: string;\n updatedAt: string;\n {{#unless this.isSubmissions}}\n group?: string;\n publishedAt?: string;\n _draft?: boolean;\n _published?: boolean;\n scheduledPublishAt?: string | null;\n scheduledUnpublishAt?: string | null;\n {{else}}\n _formId: string;\n _content: unknown;\n _formSchema: unknown;\n _attachments: StorageItemType[];\n {{/unless}}\n {{#each this.columns}}\n {{this.name}}{{#unless this.required}}?{{/unless}}: {{typeName this}};\n {{/each}}\n {{#if this.enableForm}}\n formSchema: FormValidationRules;\n {{/if}}\n};\n\nexport type {{toCodeTypeName this.name}}CreateInput = {\n {{#unless this.isSubmissions}}\n group?: string;\n publishedAt?: string;\n scheduledPublishAt?: string | null;\n scheduledUnpublishAt?: string | null;\n createdAt?: string;\n {{/unless}}\n {{#each this.columns}}\n {{this.name}}{{#unless this.required}}?{{/unless}}: {{typeName this}};\n {{/each}}\n {{#if this.enableForm}}\n formSchema: FormValidationRules;\n {{/if}}\n};\n\nexport type {{toCodeTypeName this.name}}UpdateInput = {\n {{#each this.columns}}\n {{#unless this.readOnly}}{{this.name}}?: {{typeName this}}{{#unless this.required}} | null{{/unless}};{{/unless}}\n {{/each}}\n {{#unless this.isSubmissions}}\n publishedAt?: string;\n scheduledPublishAt?: string | null;\n scheduledUnpublishAt?: string | null;\n createdAt?: string;\n {{/unless}}\n {{#if this.enableForm}}\n formSchema: FormValidationRules;\n {{/if}}\n};\n{{/each}}\n\n// Module types\n{{#each tableModules}}\nexport type {{toCodeTypeName this.name}} = {\n id?: string;\n {{#each this.columns}}\n {{this.name}}{{#unless this.required}}?{{/unless}}: {{typeName this}};\n {{/each}}\n};\n{{/each}}\n\n\n// Descriptor types\n{{#each tables}}\nexport type {{toCodeTypeName this.name}}__Descriptor = {\n row: {{toCodeTypeName this.name}};\n create: {{toCodeTypeName this.name}}CreateInput;\n update: {{toCodeTypeName this.name}}UpdateInput;\n {{#if (filterRefColumn this.columns)}}\n refs: {\n {{#each (filterRefColumn this.columns)}}\n {{includeName this}}: {{{includeType this}}};\n {{/each}}\n }\n {{/if}}\n {{#unless (filterRefColumn this.columns)}}\n refs: object;\n {{/unless}}\n {{#if (filterUniqueIndexes this.indexes)}}\n unique: [\n {{#each (filterUniqueIndexes this.indexes)}}\n { {{#each (getIndexColumns ../this this)}}{{this.name}}:{{typeName this}},{{/each}} },\n {{/each}}\n ]\n {{/if}}\n {{#unless (filterUniqueIndexes this.indexes)}}\n unique: [];\n {{/unless}}\n {{#if this.enableDrafts}}\n enableDrafts: true;\n {{/if}}\n {{#if this.enableForm}}\n submissionDescriptor: {{toCodeTypeName this.name}}_Submission__Descriptor;\n {{else}}\n submissionDescriptor: never;\n {{/if}}\n};\n{{/each}}\n\n\n{{#each tableModules}}\nexport type {{toCodeTypeName this.name}}__Descriptor = {\n row: {{toCodeTypeName this.name}};\n {{#if (filterRefColumn this.columns)}}\n refs: {\n {{#each (filterRefColumn this.columns)}}\n {{includeName this}}: {{{includeType this}}};\n {{/each}}\n }\n {{/if}}\n {{#unless (filterRefColumn this.columns)}}\n refs: object;\n {{/unless}}\n unique:[]\n};\n{{/each}}\n\n\n// Webhook types\nexport type WebhookEvent = "content.create" | "content.update" | "content.delete";\nexport type WebhookPayload = {\n event: WebhookEvent;\n timestamp: string;\n project: string;\n} & (\n {{#each tables}}\n | {\n table: "{{this.name}}";\n content: {{toCodeTypeName this.name}};\n old?: {{toCodeTypeName this.name}};\n }\n {{/each}}\n)\n';
@@ -160,15 +136,15 @@ var types_ts_default = '// This file was automatically generated and should not
160
136
  var client_ts_default = '// This file was automatically generated and should not be edited.\n\nimport { OrizmCMSClient } from "@orizm/cms-sdk";\n\nimport * as Models from "./types";\n\nexport class CMSClient {\n constructor(protected client: OrizmCMSClient) {\n this.tables = {\n {{#each tables}}\n {{toEndpointName this.name}}: this.client.getTableClient<Models.{{toCodeTypeName this.name}}__Descriptor>("{{toEndpointName this.name}}"),\n {{/each}}\n };\n\n this.buckets = {\n {{#each buckets}}\n {{toEndpointName this.name}}: this.client.getBucketClient("{{toEndpointName this.name}}"),\n {{/each}}\n };\n\n this.userManagement = this.client.userManagement;\n \n this.userinfo = this.client.userinfo;\n \n this.auth = this.client.auth;\n }\n\n readonly tables;\n readonly buckets;\n readonly userManagement;\n readonly userinfo;\n readonly auth;\n}\n';
161
137
 
162
138
  // src/cms/generate/generator.ts
163
- import_handlebars.default.registerHelper("toEndpointName", (str) => {
139
+ Handlebars.registerHelper("toEndpointName", (str) => {
164
140
  return str;
165
141
  });
166
142
  function toCodeTypeName(str) {
167
143
  str = str.charAt(0).toUpperCase() + str.slice(1);
168
144
  return str.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
169
145
  }
170
- import_handlebars.default.registerHelper("toCodeTypeName", toCodeTypeName);
171
- import_handlebars.default.registerHelper(
146
+ Handlebars.registerHelper("toCodeTypeName", toCodeTypeName);
147
+ Handlebars.registerHelper(
172
148
  "typeName",
173
149
  (column) => {
174
150
  if (column.type === "reference") {
@@ -186,7 +162,7 @@ import_handlebars.default.registerHelper(
186
162
  }
187
163
  }
188
164
  );
189
- import_handlebars.default.registerHelper(
165
+ Handlebars.registerHelper(
190
166
  "filterRefColumn",
191
167
  (columns) => {
192
168
  return (columns || []).filter(
@@ -194,13 +170,13 @@ import_handlebars.default.registerHelper(
194
170
  );
195
171
  }
196
172
  );
197
- import_handlebars.default.registerHelper(
173
+ Handlebars.registerHelper(
198
174
  "includeName",
199
175
  (column) => {
200
176
  return column.type === "reference" ? column.includeName : column.name;
201
177
  }
202
178
  );
203
- import_handlebars.default.registerHelper(
179
+ Handlebars.registerHelper(
204
180
  "includeType",
205
181
  (column) => {
206
182
  if (column.type === "reference")
@@ -213,13 +189,13 @@ import_handlebars.default.registerHelper(
213
189
  )}__Descriptor>`;
214
190
  }
215
191
  );
216
- import_handlebars.default.registerHelper(
192
+ Handlebars.registerHelper(
217
193
  "filterUniqueIndexes",
218
194
  (indexes) => {
219
195
  return (indexes || []).filter((i) => i.unique);
220
196
  }
221
197
  );
222
- import_handlebars.default.registerHelper(
198
+ Handlebars.registerHelper(
223
199
  "getIndexColumns",
224
200
  (table, index) => {
225
201
  return index.columns.map((i) => {
@@ -233,7 +209,7 @@ import_handlebars.default.registerHelper(
233
209
  );
234
210
  async function generate(options) {
235
211
  const config = options.projectDef;
236
- await (0, import_promises.mkdir)(options.output, { recursive: true });
212
+ await mkdir(options.output, { recursive: true });
237
213
  await renderTypes(config, options.output);
238
214
  await renderClient(config, options.output);
239
215
  }
@@ -247,19 +223,19 @@ async function renderTypes(config, output) {
247
223
  ...config,
248
224
  tables: [...config.tables, ...submissionTables]
249
225
  };
250
- const rendered = import_handlebars.default.compile(types_ts_default)(renderParams);
251
- const targetPath = import_path.default.join(output, "types.ts");
252
- await (0, import_promises.writeFile)(targetPath, rendered, "utf-8");
226
+ const rendered = Handlebars.compile(types_ts_default)(renderParams);
227
+ const targetPath = path.join(output, "types.ts");
228
+ await writeFile(targetPath, rendered, "utf-8");
253
229
  }
254
230
  async function renderClient(config, output) {
255
- const rendered = import_handlebars.default.compile(client_ts_default)(config);
256
- const targetPath = import_path.default.join(output, "client.ts");
257
- await (0, import_promises.writeFile)(targetPath, rendered, "utf-8");
231
+ const rendered = Handlebars.compile(client_ts_default)(config);
232
+ const targetPath = path.join(output, "client.ts");
233
+ await writeFile(targetPath, rendered, "utf-8");
258
234
  }
259
235
 
260
236
  // src/cms/generate/command.ts
261
237
  var spinner = createSpinner();
262
- var cmsGenerateCommand = new import_commander.Command("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
238
+ var cmsGenerateCommand = new Command("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
263
239
  try {
264
240
  spinner.start("Loading project schema...");
265
241
  const projectDef = await loadConfig(options.config);
@@ -276,14 +252,14 @@ var cmsGenerateCommand = new import_commander.Command("generate").description("g
276
252
  });
277
253
 
278
254
  // src/cms/pull/command.ts
279
- var import_commander2 = require("commander");
255
+ import { Command as Command2 } from "commander";
280
256
 
281
257
  // src/api/developer-api-client.ts
282
- var import_openapi_fetch = __toESM(require("openapi-fetch"));
258
+ import createClient from "openapi-fetch";
283
259
  function createDeveloperAPIClient(baseUrl, apiKey) {
284
260
  const url = new URL(baseUrl);
285
261
  url.pathname = `/api/dev/v1`;
286
- return (0, import_openapi_fetch.default)({
262
+ return createClient({
287
263
  baseUrl: url.toString(),
288
264
  headers: {
289
265
  "x-api-key": apiKey
@@ -329,9 +305,9 @@ async function fetchDefinitionReference(options) {
329
305
  }
330
306
 
331
307
  // src/lib/load-env.ts
332
- var import_promises2 = __toESM(require("fs/promises"));
333
- var v3 = __toESM(require("valibot"));
334
- var import_dotenv = __toESM(require("dotenv"));
308
+ import fs from "fs/promises";
309
+ import * as v3 from "valibot";
310
+ import dotenv from "dotenv";
335
311
  var DEFAULT_ENV_FILE_PATH = ".env";
336
312
  var EnvSchema = v3.object({
337
313
  ORIZM_PROJECT: v3.pipe(
@@ -355,15 +331,15 @@ var EnvSchema = v3.object({
355
331
  async function loadEnv(envPath) {
356
332
  let envFileContent;
357
333
  if (envPath) {
358
- envFileContent = await import_promises2.default.readFile(envPath, "utf-8").catch(() => null);
334
+ envFileContent = await fs.readFile(envPath, "utf-8").catch(() => null);
359
335
  if (!envFileContent) {
360
336
  throw new Error(`Environment variables file: '${envPath}' is not found.`);
361
337
  }
362
338
  } else {
363
- envFileContent = await import_promises2.default.readFile(DEFAULT_ENV_FILE_PATH, "utf-8").catch(() => null);
339
+ envFileContent = await fs.readFile(DEFAULT_ENV_FILE_PATH, "utf-8").catch(() => null);
364
340
  }
365
341
  if (envFileContent !== null) {
366
- const dotenvParsed = import_dotenv.default.parse(envFileContent);
342
+ const dotenvParsed = dotenv.parse(envFileContent);
367
343
  const envParseResult = v3.safeParse(EnvSchema, dotenvParsed);
368
344
  if (!envParseResult.success) {
369
345
  throw new Error(
@@ -404,7 +380,7 @@ async function pullAction(options) {
404
380
  }
405
381
 
406
382
  // src/cms/pull/command.ts
407
- var cmsPullCommand = new import_commander2.Command("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
383
+ var cmsPullCommand = new Command2("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
408
384
  try {
409
385
  await pullAction({
410
386
  destination: options.output,
@@ -416,12 +392,12 @@ var cmsPullCommand = new import_commander2.Command("pull").description("pull ori
416
392
  });
417
393
 
418
394
  // src/consumer/generate/command.ts
419
- var import_commander3 = require("commander");
395
+ import { Command as Command3 } from "commander";
420
396
 
421
397
  // src/consumer/pull/generate.ts
422
- var import_promises3 = require("fs/promises");
423
- var import_path2 = __toESM(require("path"));
424
- var import_handlebars2 = __toESM(require("handlebars"));
398
+ import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
399
+ import path2 from "path";
400
+ import Handlebars2 from "handlebars";
425
401
 
426
402
  // src/consumer/templates/client.ts.hbr
427
403
  var client_ts_default2 = '// This file was automatically generated and should not be edited.\n\nimport { ConsumerClientOptions, OrizmConsumerClientBase } from "@orizm/consumer-sdk";\nimport * as Models from "./types";\n\nexport class OrizmClient extends OrizmConsumerClientBase {\n constructor(options: ConsumerClientOptions) {\n super(options);\n }\n\n readonly tables = {\n {{#each tables}}\n {{toEndpointName this.name}}: this.getTableClient<Models.{{toCodeTypeName this.name}}__Descriptor>("{{toEndpointName this.name}}"),\n {{/each}}\n };\n}\n';
@@ -431,19 +407,19 @@ var types_ts_default2 = '// This file was automatically generated and should no
431
407
 
432
408
  // src/consumer/pull/generate.ts
433
409
  async function generate2(options) {
434
- await (0, import_promises3.mkdir)(options.output, { recursive: true });
410
+ await mkdir2(options.output, { recursive: true });
435
411
  await renderTypes2(options.definition, options.output);
436
412
  await renderClient2(options.definition, options.output);
437
413
  }
438
- import_handlebars2.default.registerHelper("toEndpointName", (str) => {
414
+ Handlebars2.registerHelper("toEndpointName", (str) => {
439
415
  return str;
440
416
  });
441
417
  function toCodeTypeName2(str) {
442
418
  str = str.charAt(0).toUpperCase() + str.slice(1);
443
419
  return str.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
444
420
  }
445
- import_handlebars2.default.registerHelper("toCodeTypeName", toCodeTypeName2);
446
- import_handlebars2.default.registerHelper("typeName", (column) => {
421
+ Handlebars2.registerHelper("toCodeTypeName", toCodeTypeName2);
422
+ Handlebars2.registerHelper("typeName", (column) => {
447
423
  if (column.type === "reference") {
448
424
  return "string";
449
425
  } else if (column.type == "json") {
@@ -464,15 +440,15 @@ import_handlebars2.default.registerHelper("typeName", (column) => {
464
440
  return column.type;
465
441
  }
466
442
  });
467
- import_handlebars2.default.registerHelper("filterRefColumn", (columns) => {
443
+ Handlebars2.registerHelper("filterRefColumn", (columns) => {
468
444
  return (columns || []).filter(
469
445
  (c) => c.type === "reference" && c.tableName && c.includeName || c.type === "module" && c.moduleName || c.type === "module-array" && c.moduleName
470
446
  );
471
447
  });
472
- import_handlebars2.default.registerHelper("includeName", (column) => {
448
+ Handlebars2.registerHelper("includeName", (column) => {
473
449
  return column.type === "reference" ? column.includeName : column.name;
474
450
  });
475
- import_handlebars2.default.registerHelper("includeType", (column) => {
451
+ Handlebars2.registerHelper("includeType", (column) => {
476
452
  if (column.type === "reference" && column.tableName)
477
453
  return toCodeTypeName2(column.tableName) + "__Descriptor";
478
454
  if (column.type === "module" && column.moduleName)
@@ -480,13 +456,13 @@ import_handlebars2.default.registerHelper("includeType", (column) => {
480
456
  if (column.type === "module-array" && column.moduleName)
481
457
  return `_ArrayModuleRef<${toCodeTypeName2(column.moduleName)}__Descriptor>`;
482
458
  });
483
- import_handlebars2.default.registerHelper(
459
+ Handlebars2.registerHelper(
484
460
  "filterUniqueIndexes",
485
461
  (indexes) => {
486
462
  return (indexes || []).filter((i) => i.unique);
487
463
  }
488
464
  );
489
- import_handlebars2.default.registerHelper(
465
+ Handlebars2.registerHelper(
490
466
  "getIndexColumns",
491
467
  (table, index) => {
492
468
  return index.columns.map((i) => {
@@ -499,14 +475,14 @@ import_handlebars2.default.registerHelper(
499
475
  }
500
476
  );
501
477
  async function renderTypes2(config, output) {
502
- const rendered = import_handlebars2.default.compile(types_ts_default2)(config);
503
- const targetPath = import_path2.default.join(output, "types.ts");
504
- await (0, import_promises3.writeFile)(targetPath, rendered, "utf-8");
478
+ const rendered = Handlebars2.compile(types_ts_default2)(config);
479
+ const targetPath = path2.join(output, "types.ts");
480
+ await writeFile2(targetPath, rendered, "utf-8");
505
481
  }
506
482
  async function renderClient2(config, output) {
507
- const rendered = import_handlebars2.default.compile(client_ts_default2)(config);
508
- const targetPath = import_path2.default.join(output, "client.ts");
509
- await (0, import_promises3.writeFile)(targetPath, rendered, "utf-8");
483
+ const rendered = Handlebars2.compile(client_ts_default2)(config);
484
+ const targetPath = path2.join(output, "client.ts");
485
+ await writeFile2(targetPath, rendered, "utf-8");
510
486
  }
511
487
 
512
488
  // src/consumer/generate/action.ts
@@ -524,7 +500,7 @@ async function generateAction(orizmConfigTs, destination) {
524
500
  }
525
501
 
526
502
  // src/consumer/generate/command.ts
527
- var consumerGenerateCommand = new import_commander3.Command("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
503
+ var consumerGenerateCommand = new Command3("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
528
504
  try {
529
505
  await generateAction(options.config, options.output);
530
506
  } catch (error2) {
@@ -533,7 +509,7 @@ var consumerGenerateCommand = new import_commander3.Command("generate").descript
533
509
  });
534
510
 
535
511
  // src/consumer/pull/command.ts
536
- var import_commander4 = require("commander");
512
+ import { Command as Command4 } from "commander";
537
513
 
538
514
  // src/consumer/pull/action.ts
539
515
  var spinner4 = createSpinner();
@@ -557,7 +533,7 @@ async function pullAction2(options) {
557
533
  }
558
534
 
559
535
  // src/consumer/pull/command.ts
560
- var consumerPullCommand = new import_commander4.Command("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
536
+ var consumerPullCommand = new Command4("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
561
537
  try {
562
538
  await pullAction2({
563
539
  destination: options.output,
@@ -569,8 +545,8 @@ var consumerPullCommand = new import_commander4.Command("pull").description("pul
569
545
  });
570
546
 
571
547
  // src/push/command.ts
572
- var import_commander5 = require("commander");
573
- var import_cli_color3 = require("cli-color");
548
+ import { Command as Command5 } from "commander";
549
+ import cliColor4 from "cli-color";
574
550
 
575
551
  // src/lib/developer-api.ts
576
552
  async function applyDefinition(env, projectDef) {
@@ -623,7 +599,7 @@ var getChangeEvents = async (env, projectDef) => {
623
599
  };
624
600
 
625
601
  // src/lib/display-change-events.ts
626
- var import_cli_color2 = require("cli-color");
602
+ import cliColor3 from "cli-color";
627
603
 
628
604
  // src/lib/cli-table.ts
629
605
  var COLORS = {
@@ -732,7 +708,7 @@ async function displayChangeEvents(changeEvents) {
732
708
  } = changeEvents;
733
709
  if (tableChangeEvents.length === 0 && bucketChangeEvents.length === 0 && authorityChangeEvents.length === 0) {
734
710
  console.log();
735
- console.log((0, import_cli_color2.green)("No changes."));
711
+ console.log(cliColor3.green("No changes."));
736
712
  return;
737
713
  }
738
714
  displayTableChangeEvents(tableChangeEvents);
@@ -970,9 +946,9 @@ function displayAuthorityChangeEvents(authorityChangeEvents) {
970
946
  }
971
947
 
972
948
  // src/lib/cli-input.ts
973
- var import_promises4 = require("readline/promises");
949
+ import { createInterface } from "node:readline/promises";
974
950
  async function input(prompt) {
975
- const rl = (0, import_promises4.createInterface)({
951
+ const rl = createInterface({
976
952
  input: process.stdin,
977
953
  output: process.stdout
978
954
  });
@@ -984,7 +960,7 @@ async function input(prompt) {
984
960
 
985
961
  // src/push/command.ts
986
962
  var spinner5 = createSpinner();
987
- var pushCommand = new import_commander5.Command("push").description("apply schema to project.").option("-e, --env <path>", "env file path.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("--dry-run", "display change-events without applying schema.", false).option("-y, --yes", "apply schema without confirmation.", false).action(async (options) => {
963
+ var pushCommand = new Command5("push").description("apply schema to project.").option("-e, --env <path>", "env file path.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("--dry-run", "display change-events without applying schema.", false).option("-y, --yes", "apply schema without confirmation.", false).action(async (options) => {
988
964
  try {
989
965
  spinner5.start("Loading environment variables...");
990
966
  const env = await loadEnv(options.env);
@@ -1005,7 +981,7 @@ var pushCommand = new import_commander5.Command("push").description("apply schem
1005
981
  if (!options.yes) {
1006
982
  const confirm = await input("Do you want to apply schema? (y/N): ");
1007
983
  if (confirm !== "y") {
1008
- console.log((0, import_cli_color3.red)("Canceled."));
984
+ console.log(cliColor4.red("Canceled."));
1009
985
  return;
1010
986
  }
1011
987
  }
@@ -1018,16 +994,16 @@ var pushCommand = new import_commander5.Command("push").description("apply schem
1018
994
  });
1019
995
 
1020
996
  // src/cli.ts
1021
- import_commander6.program.name("orizm CLI");
1022
- import_commander6.program.addCommand(pushCommand);
1023
- var cmsCommands = new import_commander6.Command("cms").description("cms commands.");
997
+ program.name("orizm CLI");
998
+ program.addCommand(pushCommand);
999
+ var cmsCommands = new Command6("cms").description("cms commands.");
1024
1000
  cmsCommands.addCommand(cmsGenerateCommand);
1025
1001
  cmsCommands.addCommand(cmsPullCommand);
1026
- import_commander6.program.addCommand(cmsCommands);
1027
- var consumerCommands = new import_commander6.Command("consumer").description(
1002
+ program.addCommand(cmsCommands);
1003
+ var consumerCommands = new Command6("consumer").description(
1028
1004
  "consumer commands."
1029
1005
  );
1030
1006
  consumerCommands.addCommand(consumerGenerateCommand);
1031
1007
  consumerCommands.addCommand(consumerPullCommand);
1032
- import_commander6.program.addCommand(consumerCommands);
1033
- import_commander6.program.parse();
1008
+ program.addCommand(consumerCommands);
1009
+ program.parse();
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@orizm/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Orizm CLI",
5
+ "type": "module",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/chot-Inc/superx.git",
@@ -19,7 +20,7 @@
19
20
  "handlebars": "^4.7.7",
20
21
  "openapi-fetch": "^0.12.2",
21
22
  "valibot": "^1.0.0",
22
- "@orizm/common": "1.13.0"
23
+ "@orizm/common": "1.13.1"
23
24
  },
24
25
  "bin": {
25
26
  "orizm": "bin/index.js"