@wato787/microcms-cli 0.1.1 → 0.1.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.
@@ -16,12 +16,16 @@ export function resolveConfig(options) {
16
16
  const serviceDomain = toStringValue(options.serviceDomain) ??
17
17
  toStringValue(process.env.MICROCMS_SERVICE_DOMAIN);
18
18
  if (!serviceDomain) {
19
- throw new Error('MICROCMS_SERVICE_DOMAIN is required. You can also pass --service-domain.');
19
+ const envDir = process.env.__MICROCMS_CLI_ENV_DIR ?? process.cwd();
20
+ throw new Error('MICROCMS_SERVICE_DOMAIN is required. You can also pass --service-domain.\n' +
21
+ `(Searched for .env / .env.local in: ${envDir}. CWD: ${process.cwd()})`);
20
22
  }
21
23
  const apiKey = toStringValue(options.apiKey) ??
22
24
  toStringValue(process.env.MICROCMS_MANAGEMENT_API_KEY);
23
25
  if (!apiKey) {
24
- throw new Error('MICROCMS_MANAGEMENT_API_KEY is required. You can also pass --api-key.');
26
+ const envDir = process.env.__MICROCMS_CLI_ENV_DIR ?? process.cwd();
27
+ throw new Error('MICROCMS_MANAGEMENT_API_KEY is required. You can also pass --api-key.\n' +
28
+ `(Searched for .env / .env.local in: ${envDir}. CWD: ${process.cwd()})`);
25
29
  }
26
30
  return { serviceDomain, apiKey };
27
31
  }
@@ -57,6 +57,7 @@ function resolveFieldType(field, context) {
57
57
  case 'textArea':
58
58
  case 'richEditor':
59
59
  case 'richEditorV2':
60
+ case 'richEditorOld':
60
61
  case 'date':
61
62
  return 'string';
62
63
  case 'number':
@@ -67,12 +68,17 @@ function resolveFieldType(field, context) {
67
68
  return 'MicroCMSImage';
68
69
  case 'mediaList':
69
70
  return 'MicroCMSImage[]';
71
+ case 'file':
72
+ return 'MicroCMSFile';
70
73
  case 'relation':
71
74
  return 'MicroCMSContentId';
72
75
  case 'relationList':
73
76
  return 'MicroCMSContentId[]';
74
77
  case 'select':
75
78
  return field.multipleSelect ? 'string[]' : 'string';
79
+ case 'iframe':
80
+ case 'extension':
81
+ return 'Record<string, unknown>';
76
82
  case 'custom':
77
83
  if (!field.customFieldCreatedAt) {
78
84
  return 'Record<string, unknown>';
@@ -166,6 +172,11 @@ export function renderDefinitionsFile(targets) {
166
172
  ' alt?: string;',
167
173
  '}',
168
174
  '',
175
+ 'export interface MicroCMSFile {',
176
+ ' url: string;',
177
+ ' fileSize?: number;',
178
+ '}',
179
+ '',
169
180
  'export interface MicroCMSListResponse<T> {',
170
181
  ' contents: (T & MicroCMSListContent)[];',
171
182
  ' totalCount: number;',
package/dist/index.js CHANGED
@@ -1,15 +1,28 @@
1
1
  #!/usr/bin/env node
2
+ import fs from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import dotenv from 'dotenv';
4
- dotenv.config();
5
- dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
5
+ function findEnvDir(dir) {
6
+ const parent = path.dirname(dir);
7
+ if (dir === parent)
8
+ return null;
9
+ const env = path.join(dir, '.env');
10
+ const envLocal = path.join(dir, '.env.local');
11
+ if (fs.existsSync(env) || fs.existsSync(envLocal))
12
+ return dir;
13
+ return findEnvDir(parent);
14
+ }
15
+ const envDir = findEnvDir(process.cwd()) ?? process.cwd();
16
+ dotenv.config({ path: path.join(envDir, '.env') });
17
+ dotenv.config({ path: path.join(envDir, '.env.local') });
18
+ process.env.__MICROCMS_CLI_ENV_DIR = envDir;
6
19
  import { Command } from 'commander';
7
20
  import { genTypesCommand } from './commands/gen-types/index.js';
8
21
  const program = new Command();
9
22
  program
10
23
  .name('microcms-cli')
11
24
  .description('CLI for microCMS')
12
- .version('0.1.1');
25
+ .version('0.1.2');
13
26
  program
14
27
  .command('gen-types [endpointId]')
15
28
  .description('Fetch API schema from microCMS Management API and generate TypeScript types')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wato787/microcms-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "AI-friendly CLI tool for microCMS, built with Bun",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",