@atcute/lex-cli 2.8.0 → 2.8.1
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/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +35 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/export.d.ts +2 -8
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +1 -12
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/generate.d.ts +2 -8
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +1 -12
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/pull.d.ts +2 -8
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +1 -12
- package/dist/commands/pull.js.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +65 -7
- package/src/commands/export.ts +2 -22
- package/src/commands/generate.ts +2 -22
- package/src/commands/pull.ts +2 -22
- package/dist/shared-options.d.ts +0 -6
- package/dist/shared-options.d.ts.map +0 -1
- package/dist/shared-options.js +0 -11
- package/dist/shared-options.js.map +0 -1
- package/src/shared-options.ts +0 -13
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
import { type InferValue } from '@optique/core/parser';
|
|
2
|
+
declare const generateCommandSchema: import("@optique/core/parser").Parser<"sync", {
|
|
3
|
+
readonly type: "generate";
|
|
4
|
+
} & {
|
|
5
|
+
readonly config: string | undefined;
|
|
6
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
7
|
+
declare const pullCommandSchema: import("@optique/core/parser").Parser<"sync", {
|
|
8
|
+
readonly type: "pull";
|
|
9
|
+
} & {
|
|
10
|
+
readonly config: string | undefined;
|
|
11
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
12
|
+
declare const exportCommandSchema: import("@optique/core/parser").Parser<"sync", {
|
|
13
|
+
readonly type: "export";
|
|
14
|
+
} & {
|
|
15
|
+
readonly config: string | undefined;
|
|
16
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
17
|
+
export type GenerateCommand = InferValue<typeof generateCommandSchema>;
|
|
18
|
+
export type PullCommand = InferValue<typeof pullCommandSchema>;
|
|
19
|
+
export type ExportCommand = InferValue<typeof exportCommandSchema>;
|
|
1
20
|
export {};
|
|
2
21
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAavD,QAAA,MAAM,qBAAqB;;;;mFAY1B,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;mFAYtB,CAAC;AAEF,QAAA,MAAM,mBAAmB;;;;mFAYxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACvE,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC/D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
|
-
import { or } from '@optique/core/constructs';
|
|
1
|
+
import { merge, object, or } from '@optique/core/constructs';
|
|
2
|
+
import { message } from '@optique/core/message';
|
|
3
|
+
import { optional } from '@optique/core/modifiers';
|
|
4
|
+
import {} from '@optique/core/parser';
|
|
5
|
+
import { command, constant, option } from '@optique/core/primitives';
|
|
2
6
|
import { run } from '@optique/run';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
import { path as pathParser } from '@optique/run/valueparser';
|
|
8
|
+
const sharedOptions = object(`Global options`, {
|
|
9
|
+
config: optional(option('-c', '--config', pathParser({ metavar: 'CONFIG' }), {
|
|
10
|
+
description: message `path to the lexicon configuration file. defaults to searching for lex.config.js or lex.config.ts in the current directory.`,
|
|
11
|
+
})),
|
|
12
|
+
});
|
|
13
|
+
const generateCommandSchema = command('generate', merge(object({
|
|
14
|
+
type: constant('generate'),
|
|
15
|
+
}), sharedOptions), {
|
|
16
|
+
brief: message `generate type definitions from lexicon documents`,
|
|
17
|
+
description: message `reads lexicon documents from the configured files and generates TypeScript type definitions and runtime validators.`,
|
|
18
|
+
});
|
|
19
|
+
const pullCommandSchema = command('pull', merge(object({
|
|
20
|
+
type: constant('pull'),
|
|
21
|
+
}), sharedOptions), {
|
|
22
|
+
brief: message `pull lexicon documents from configured sources`,
|
|
23
|
+
description: message `fetches lexicon documents from configured git repositories and writes them to the output directory.`,
|
|
24
|
+
});
|
|
25
|
+
const exportCommandSchema = command('export', merge(object({
|
|
26
|
+
type: constant('export'),
|
|
27
|
+
}), sharedOptions), {
|
|
28
|
+
brief: message `export lexicon documents as JSON files`,
|
|
29
|
+
description: message `exports lexicon documents (from JSON or builder files) to JSON format for publishing or distribution.`,
|
|
30
|
+
});
|
|
6
31
|
const parser = or(generateCommandSchema, pullCommandSchema, exportCommandSchema);
|
|
7
32
|
const result = run(parser, { programName: 'lex-cli', help: 'both' });
|
|
8
33
|
if (result.type === 'generate') {
|
|
9
|
-
await
|
|
34
|
+
const { handler } = await import('./commands/generate.js');
|
|
35
|
+
await handler(result);
|
|
10
36
|
}
|
|
11
37
|
else if (result.type === 'pull') {
|
|
12
|
-
await
|
|
38
|
+
const { handler } = await import('./commands/pull.js');
|
|
39
|
+
await handler(result);
|
|
13
40
|
}
|
|
14
41
|
else if (result.type === 'export') {
|
|
15
|
-
await
|
|
42
|
+
const { handler } = await import('./commands/export.js');
|
|
43
|
+
await handler(result);
|
|
16
44
|
}
|
|
17
45
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAmB,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE;IAC9C,MAAM,EAAE,QAAQ,CACf,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE;QAC3D,WAAW,EAAE,OAAO,CAAA,4HAA4H;KAChJ,CAAC,CACF;CACD,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,OAAO,CACpC,UAAU,EACV,KAAK,CACJ,MAAM,CAAC;IACN,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC1B,CAAC,EACF,aAAa,CACb,EACD;IACC,KAAK,EAAE,OAAO,CAAA,kDAAkD;IAChE,WAAW,EAAE,OAAO,CAAA,qHAAqH;CACzI,CACD,CAAC;AAEF,MAAM,iBAAiB,GAAG,OAAO,CAChC,MAAM,EACN,KAAK,CACJ,MAAM,CAAC;IAC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ema: import("@optique/core/parser").Parser<"sync", {
|
|
3
|
-
readonly type: "export";
|
|
4
|
-
} & {
|
|
5
|
-
readonly config: string | undefined;
|
|
6
|
-
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
7
|
-
export type ExportCommand = InferValue<typeof exportCommandSchema>;
|
|
1
|
+
import type { ExportCommand } from '../cli.ts';
|
|
8
2
|
/**
|
|
9
3
|
* runs the export command to write lexicon documents as JSON files
|
|
10
4
|
* @param args parsed command arguments
|
|
11
5
|
*/
|
|
12
|
-
export declare const
|
|
6
|
+
export declare const handler: (args: ExportCommand) => Promise<void>;
|
|
13
7
|
//# sourceMappingURL=export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAmC/C;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAgB,aAAa,KAAG,OAAO,CAAC,IAAI,CAqC/D,CAAC"}
|
package/dist/commands/export.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import { merge, object } from '@optique/core/constructs';
|
|
4
|
-
import { message } from '@optique/core/message';
|
|
5
|
-
import {} from '@optique/core/parser';
|
|
6
|
-
import { command, constant } from '@optique/core/primitives';
|
|
7
3
|
import pc from 'picocolors';
|
|
8
4
|
import { loadConfig } from '../config.js';
|
|
9
5
|
import { createFormatter } from '../formatter.js';
|
|
10
6
|
import { loadLexicons } from '../lexicon-loader.js';
|
|
11
|
-
import { sharedOptions } from '../shared-options.js';
|
|
12
|
-
export const exportCommandSchema = command('export', merge(object({
|
|
13
|
-
type: constant('export'),
|
|
14
|
-
}), sharedOptions), {
|
|
15
|
-
brief: message `export lexicon documents as JSON files`,
|
|
16
|
-
description: message `exports lexicon documents (from JSON or builder files) to JSON format for publishing or distribution.`,
|
|
17
|
-
});
|
|
18
7
|
/**
|
|
19
8
|
* ensures export configuration is present
|
|
20
9
|
* @param config the normalized config
|
|
@@ -39,7 +28,7 @@ const writeLexicon = async (outdir, nsid, doc, formatter) => {
|
|
|
39
28
|
* runs the export command to write lexicon documents as JSON files
|
|
40
29
|
* @param args parsed command arguments
|
|
41
30
|
*/
|
|
42
|
-
export const
|
|
31
|
+
export const handler = async (args) => {
|
|
43
32
|
const config = await loadConfig(args.config);
|
|
44
33
|
const exportConfig = ensureExportConfig(config);
|
|
45
34
|
// use export.files if specified, otherwise fall back to generate.files
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,UAAU,EAA4C,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAAwB,EAAgB,EAAE;IACrE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,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AAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const generateCommandSchema: import("@optique/core/parser").Parser<"sync", {
|
|
3
|
-
readonly type: "generate";
|
|
4
|
-
} & {
|
|
5
|
-
readonly config: string | undefined;
|
|
6
|
-
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
7
|
-
export type GenerateCommand = InferValue<typeof generateCommandSchema>;
|
|
1
|
+
import type { GenerateCommand } from '../cli.ts';
|
|
8
2
|
/**
|
|
9
3
|
* runs the generate command to create type definitions from lexicon documents
|
|
10
4
|
* @param args parsed command arguments
|
|
11
5
|
*/
|
|
12
|
-
export declare const
|
|
6
|
+
export declare const handler: (args: GenerateCommand) => Promise<void>;
|
|
13
7
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgJjD;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAgB,eAAe,KAAG,OAAO,CAAC,IAAI,CA8CjE,CAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as module from 'node:module';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { merge, object } from '@optique/core/constructs';
|
|
5
|
-
import { message } from '@optique/core/message';
|
|
6
|
-
import {} from '@optique/core/parser';
|
|
7
|
-
import { command, constant } from '@optique/core/primitives';
|
|
8
4
|
import pc from 'picocolors';
|
|
9
5
|
import { generateLexiconApi } from '../codegen.js';
|
|
10
6
|
import { loadConfig } from '../config.js';
|
|
11
7
|
import { createFormatter } from '../formatter.js';
|
|
12
8
|
import { loadLexicons } from '../lexicon-loader.js';
|
|
13
9
|
import { packageJsonSchema } from '../lexicon-metadata.js';
|
|
14
|
-
import { sharedOptions } from '../shared-options.js';
|
|
15
10
|
/**
|
|
16
11
|
* resolves package imports to ImportMapping[]
|
|
17
12
|
*/
|
|
@@ -108,12 +103,6 @@ const resolveImportsToMappings = async (imports, configDirname) => {
|
|
|
108
103
|
}
|
|
109
104
|
return mappings;
|
|
110
105
|
};
|
|
111
|
-
export const generateCommandSchema = command('generate', merge(object({
|
|
112
|
-
type: constant('generate'),
|
|
113
|
-
}), sharedOptions), {
|
|
114
|
-
brief: message `generate type definitions from lexicon documents`,
|
|
115
|
-
description: message `reads lexicon documents from the configured files and generates TypeScript type definitions and runtime validators.`,
|
|
116
|
-
});
|
|
117
106
|
const ensureGenerateConfig = (config) => {
|
|
118
107
|
const generate = config.generate;
|
|
119
108
|
if (!generate) {
|
|
@@ -135,7 +124,7 @@ const ensureGenerateConfig = (config) => {
|
|
|
135
124
|
* runs the generate command to create type definitions from lexicon documents
|
|
136
125
|
* @param args parsed command arguments
|
|
137
126
|
*/
|
|
138
|
-
export const
|
|
127
|
+
export const handler = async (args) => {
|
|
139
128
|
const config = await loadConfig(args.config);
|
|
140
129
|
const generateConfig = ensureGenerateConfig(config);
|
|
141
130
|
// resolve imports to mappings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC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C;YACzC,CAAC,CAAC,EAAE,CACJ,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;YAAS,CAAC;QACV,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACF,CAAC,CAAC"}
|
package/dist/commands/pull.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const pullCommandSchema: import("@optique/core/parser").Parser<"sync", {
|
|
3
|
-
readonly type: "pull";
|
|
4
|
-
} & {
|
|
5
|
-
readonly config: string | undefined;
|
|
6
|
-
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
7
|
-
export type PullCommand = InferValue<typeof pullCommandSchema>;
|
|
1
|
+
import type { PullCommand } from '../cli.ts';
|
|
8
2
|
/**
|
|
9
3
|
* runs the pull command to fetch lexicon documents from configured sources
|
|
10
4
|
* @param args parsed command arguments
|
|
11
5
|
*/
|
|
12
|
-
export declare const
|
|
6
|
+
export declare const handler: (args: PullCommand) => Promise<void>;
|
|
13
7
|
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAuJ7C;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAgB,WAAW,KAAG,OAAO,CAAC,IAAI,CA+C7D,CAAC"}
|
package/dist/commands/pull.js
CHANGED
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { lexiconDoc, refineLexiconDoc } from '@atcute/lexicon-doc';
|
|
4
|
-
import { merge, object } from '@optique/core/constructs';
|
|
5
|
-
import { message } from '@optique/core/message';
|
|
6
|
-
import {} from '@optique/core/parser';
|
|
7
|
-
import { command, constant } from '@optique/core/primitives';
|
|
8
4
|
import pc from 'picocolors';
|
|
9
5
|
import { loadConfig } from '../config.js';
|
|
10
6
|
import { createFormatter } from '../formatter.js';
|
|
11
7
|
import { pullAtprotoSource } from '../pull-sources/atproto.js';
|
|
12
8
|
import { pullGitSource } from '../pull-sources/git.js';
|
|
13
|
-
import { sharedOptions } from '../shared-options.js';
|
|
14
|
-
export const pullCommandSchema = command('pull', merge(object({
|
|
15
|
-
type: constant('pull'),
|
|
16
|
-
}), sharedOptions), {
|
|
17
|
-
brief: message `pull lexicon documents from configured sources`,
|
|
18
|
-
description: message `fetches lexicon documents from configured git repositories and writes them to the output directory.`,
|
|
19
|
-
});
|
|
20
9
|
const ensurePullConfig = (config) => {
|
|
21
10
|
if (!config.pull) {
|
|
22
11
|
console.error(pc.bold(pc.red(`pull configuration missing`)));
|
|
@@ -121,7 +110,7 @@ const writeSourceReadme = async (outdir, revisions, formatter) => {
|
|
|
121
110
|
* runs the pull command to fetch lexicon documents from configured sources
|
|
122
111
|
* @param args parsed command arguments
|
|
123
112
|
*/
|
|
124
|
-
export const
|
|
113
|
+
export const handler = async (args) => {
|
|
125
114
|
const config = await loadConfig(args.config);
|
|
126
115
|
const pullConfig = ensurePullConfig(config);
|
|
127
116
|
const outdir = path.resolve(config.root, pullConfig.outdir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAmB,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":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,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5C,MAAM,OAAO,CAAC,GAAG,CAAC;YACjB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACnF,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,CAAC;SACrD,CAAC,CAAC;IACJ,CAAC;YAAS,CAAC;QACV,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atcute/lex-cli",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "cli tool to generate type definitions for atcute",
|
|
5
5
|
"license": "0BSD",
|
|
6
6
|
"repository": {
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@badrap/valita": "^0.4.6",
|
|
28
|
-
"@optique/core": "^0.
|
|
29
|
-
"@optique/run": "^0.
|
|
28
|
+
"@optique/core": "^1.0.0",
|
|
29
|
+
"@optique/run": "^1.0.0",
|
|
30
30
|
"picocolors": "^1.1.1",
|
|
31
|
-
"prettier": "^3.8.
|
|
31
|
+
"prettier": "^3.8.3",
|
|
32
32
|
"@atcute/identity": "^1.1.4",
|
|
33
|
-
"@atcute/identity-resolver": "^1.2.2",
|
|
34
33
|
"@atcute/lexicon-resolver": "^0.1.6",
|
|
34
|
+
"@atcute/identity-resolver": "^1.2.2",
|
|
35
35
|
"@atcute/lexicon-doc": "^2.2.0",
|
|
36
36
|
"@atcute/lexicons": "^1.3.0"
|
|
37
37
|
},
|
package/src/cli.ts
CHANGED
|
@@ -1,18 +1,76 @@
|
|
|
1
|
-
import { or } from '@optique/core/constructs';
|
|
1
|
+
import { merge, object, or } from '@optique/core/constructs';
|
|
2
|
+
import { message } from '@optique/core/message';
|
|
3
|
+
import { optional } from '@optique/core/modifiers';
|
|
4
|
+
import { type InferValue } from '@optique/core/parser';
|
|
5
|
+
import { command, constant, option } from '@optique/core/primitives';
|
|
2
6
|
import { run } from '@optique/run';
|
|
7
|
+
import { path as pathParser } from '@optique/run/valueparser';
|
|
3
8
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
const sharedOptions = object(`Global options`, {
|
|
10
|
+
config: optional(
|
|
11
|
+
option('-c', '--config', pathParser({ metavar: 'CONFIG' }), {
|
|
12
|
+
description: message`path to the lexicon configuration file. defaults to searching for lex.config.js or lex.config.ts in the current directory.`,
|
|
13
|
+
}),
|
|
14
|
+
),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const generateCommandSchema = command(
|
|
18
|
+
'generate',
|
|
19
|
+
merge(
|
|
20
|
+
object({
|
|
21
|
+
type: constant('generate'),
|
|
22
|
+
}),
|
|
23
|
+
sharedOptions,
|
|
24
|
+
),
|
|
25
|
+
{
|
|
26
|
+
brief: message`generate type definitions from lexicon documents`,
|
|
27
|
+
description: message`reads lexicon documents from the configured files and generates TypeScript type definitions and runtime validators.`,
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const pullCommandSchema = command(
|
|
32
|
+
'pull',
|
|
33
|
+
merge(
|
|
34
|
+
object({
|
|
35
|
+
type: constant('pull'),
|
|
36
|
+
}),
|
|
37
|
+
sharedOptions,
|
|
38
|
+
),
|
|
39
|
+
{
|
|
40
|
+
brief: message`pull lexicon documents from configured sources`,
|
|
41
|
+
description: message`fetches lexicon documents from configured git repositories and writes them to the output directory.`,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const exportCommandSchema = command(
|
|
46
|
+
'export',
|
|
47
|
+
merge(
|
|
48
|
+
object({
|
|
49
|
+
type: constant('export'),
|
|
50
|
+
}),
|
|
51
|
+
sharedOptions,
|
|
52
|
+
),
|
|
53
|
+
{
|
|
54
|
+
brief: message`export lexicon documents as JSON files`,
|
|
55
|
+
description: message`exports lexicon documents (from JSON or builder files) to JSON format for publishing or distribution.`,
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export type GenerateCommand = InferValue<typeof generateCommandSchema>;
|
|
60
|
+
export type PullCommand = InferValue<typeof pullCommandSchema>;
|
|
61
|
+
export type ExportCommand = InferValue<typeof exportCommandSchema>;
|
|
7
62
|
|
|
8
63
|
const parser = or(generateCommandSchema, pullCommandSchema, exportCommandSchema);
|
|
9
64
|
|
|
10
65
|
const result = run(parser, { programName: 'lex-cli', help: 'both' });
|
|
11
66
|
|
|
12
67
|
if (result.type === 'generate') {
|
|
13
|
-
await
|
|
68
|
+
const { handler } = await import('./commands/generate.ts');
|
|
69
|
+
await handler(result);
|
|
14
70
|
} else if (result.type === 'pull') {
|
|
15
|
-
await
|
|
71
|
+
const { handler } = await import('./commands/pull.ts');
|
|
72
|
+
await handler(result);
|
|
16
73
|
} else if (result.type === 'export') {
|
|
17
|
-
await
|
|
74
|
+
const { handler } = await import('./commands/export.ts');
|
|
75
|
+
await handler(result);
|
|
18
76
|
}
|
package/src/commands/export.ts
CHANGED
|
@@ -3,32 +3,12 @@ import * as path from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import type { LexiconDoc } from '@atcute/lexicon-doc';
|
|
5
5
|
|
|
6
|
-
import { merge, object } from '@optique/core/constructs';
|
|
7
|
-
import { message } from '@optique/core/message';
|
|
8
|
-
import { type InferValue } from '@optique/core/parser';
|
|
9
|
-
import { command, constant } from '@optique/core/primitives';
|
|
10
6
|
import pc from 'picocolors';
|
|
11
7
|
|
|
8
|
+
import type { ExportCommand } from '../cli.ts';
|
|
12
9
|
import { loadConfig, type ExportConfig, type NormalizedConfig } from '../config.ts';
|
|
13
10
|
import { createFormatter, type Formatter } from '../formatter.ts';
|
|
14
11
|
import { loadLexicons } from '../lexicon-loader.ts';
|
|
15
|
-
import { sharedOptions } from '../shared-options.ts';
|
|
16
|
-
|
|
17
|
-
export const exportCommandSchema = command(
|
|
18
|
-
'export',
|
|
19
|
-
merge(
|
|
20
|
-
object({
|
|
21
|
-
type: constant('export'),
|
|
22
|
-
}),
|
|
23
|
-
sharedOptions,
|
|
24
|
-
),
|
|
25
|
-
{
|
|
26
|
-
brief: message`export lexicon documents as JSON files`,
|
|
27
|
-
description: message`exports lexicon documents (from JSON or builder files) to JSON format for publishing or distribution.`,
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
export type ExportCommand = InferValue<typeof exportCommandSchema>;
|
|
32
12
|
|
|
33
13
|
/**
|
|
34
14
|
* ensures export configuration is present
|
|
@@ -64,7 +44,7 @@ const writeLexicon = async (
|
|
|
64
44
|
* runs the export command to write lexicon documents as JSON files
|
|
65
45
|
* @param args parsed command arguments
|
|
66
46
|
*/
|
|
67
|
-
export const
|
|
47
|
+
export const handler = async (args: ExportCommand): Promise<void> => {
|
|
68
48
|
const config = await loadConfig(args.config);
|
|
69
49
|
const exportConfig = ensureExportConfig(config);
|
|
70
50
|
|
package/src/commands/generate.ts
CHANGED
|
@@ -2,18 +2,14 @@ import * as fs from 'node:fs/promises';
|
|
|
2
2
|
import * as module from 'node:module';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
|
|
5
|
-
import { merge, object } from '@optique/core/constructs';
|
|
6
|
-
import { message } from '@optique/core/message';
|
|
7
|
-
import { type InferValue } from '@optique/core/parser';
|
|
8
|
-
import { command, constant } from '@optique/core/primitives';
|
|
9
5
|
import pc from 'picocolors';
|
|
10
6
|
|
|
7
|
+
import type { GenerateCommand } from '../cli.ts';
|
|
11
8
|
import { generateLexiconApi, type ImportMapping } from '../codegen.ts';
|
|
12
9
|
import { loadConfig, type GenerateConfig, type NormalizedConfig } from '../config.ts';
|
|
13
10
|
import { createFormatter } from '../formatter.ts';
|
|
14
11
|
import { loadLexicons } from '../lexicon-loader.ts';
|
|
15
12
|
import { packageJsonSchema } from '../lexicon-metadata.ts';
|
|
16
|
-
import { sharedOptions } from '../shared-options.ts';
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
* resolves package imports to ImportMapping[]
|
|
@@ -129,22 +125,6 @@ const resolveImportsToMappings = async (
|
|
|
129
125
|
return mappings;
|
|
130
126
|
};
|
|
131
127
|
|
|
132
|
-
export const generateCommandSchema = command(
|
|
133
|
-
'generate',
|
|
134
|
-
merge(
|
|
135
|
-
object({
|
|
136
|
-
type: constant('generate'),
|
|
137
|
-
}),
|
|
138
|
-
sharedOptions,
|
|
139
|
-
),
|
|
140
|
-
{
|
|
141
|
-
brief: message`generate type definitions from lexicon documents`,
|
|
142
|
-
description: message`reads lexicon documents from the configured files and generates TypeScript type definitions and runtime validators.`,
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
export type GenerateCommand = InferValue<typeof generateCommandSchema>;
|
|
147
|
-
|
|
148
128
|
type ResolvedGenerateConfig = GenerateConfig & { outdir: string; files: string[] };
|
|
149
129
|
|
|
150
130
|
const ensureGenerateConfig = (config: NormalizedConfig): ResolvedGenerateConfig => {
|
|
@@ -172,7 +152,7 @@ const ensureGenerateConfig = (config: NormalizedConfig): ResolvedGenerateConfig
|
|
|
172
152
|
* runs the generate command to create type definitions from lexicon documents
|
|
173
153
|
* @param args parsed command arguments
|
|
174
154
|
*/
|
|
175
|
-
export const
|
|
155
|
+
export const handler = async (args: GenerateCommand): Promise<void> => {
|
|
176
156
|
const config = await loadConfig(args.config);
|
|
177
157
|
const generateConfig = ensureGenerateConfig(config);
|
|
178
158
|
|
package/src/commands/pull.ts
CHANGED
|
@@ -3,34 +3,14 @@ import * as path from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import { lexiconDoc, refineLexiconDoc, type LexiconDoc } from '@atcute/lexicon-doc';
|
|
5
5
|
|
|
6
|
-
import { merge, object } from '@optique/core/constructs';
|
|
7
|
-
import { message } from '@optique/core/message';
|
|
8
|
-
import { type InferValue } from '@optique/core/parser';
|
|
9
|
-
import { command, constant } from '@optique/core/primitives';
|
|
10
6
|
import pc from 'picocolors';
|
|
11
7
|
|
|
8
|
+
import type { PullCommand } from '../cli.ts';
|
|
12
9
|
import { loadConfig, type NormalizedConfig, type PullConfig, type SourceConfig } from '../config.ts';
|
|
13
10
|
import { createFormatter, type Formatter } from '../formatter.ts';
|
|
14
11
|
import { pullAtprotoSource } from '../pull-sources/atproto.ts';
|
|
15
12
|
import { pullGitSource } from '../pull-sources/git.ts';
|
|
16
13
|
import type { PullResult, PulledLexicon, SourceLocation } from '../pull-sources/types.ts';
|
|
17
|
-
import { sharedOptions } from '../shared-options.ts';
|
|
18
|
-
|
|
19
|
-
export const pullCommandSchema = command(
|
|
20
|
-
'pull',
|
|
21
|
-
merge(
|
|
22
|
-
object({
|
|
23
|
-
type: constant('pull'),
|
|
24
|
-
}),
|
|
25
|
-
sharedOptions,
|
|
26
|
-
),
|
|
27
|
-
{
|
|
28
|
-
brief: message`pull lexicon documents from configured sources`,
|
|
29
|
-
description: message`fetches lexicon documents from configured git repositories and writes them to the output directory.`,
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export type PullCommand = InferValue<typeof pullCommandSchema>;
|
|
34
14
|
|
|
35
15
|
interface SourceRevision {
|
|
36
16
|
source: SourceConfig;
|
|
@@ -180,7 +160,7 @@ const writeSourceReadme = async (
|
|
|
180
160
|
* runs the pull command to fetch lexicon documents from configured sources
|
|
181
161
|
* @param args parsed command arguments
|
|
182
162
|
*/
|
|
183
|
-
export const
|
|
163
|
+
export const handler = async (args: PullCommand): Promise<void> => {
|
|
184
164
|
const config = await loadConfig(args.config);
|
|
185
165
|
const pullConfig = ensurePullConfig(config);
|
|
186
166
|
|
package/dist/shared-options.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const sharedOptions: import("@optique/core/parser").Parser<"sync", {
|
|
2
|
-
readonly config: string | undefined;
|
|
3
|
-
}, {
|
|
4
|
-
readonly config: [import("@optique/core/valueparser").ValueParserResult<string> | undefined] | undefined;
|
|
5
|
-
}>;
|
|
6
|
-
//# sourceMappingURL=shared-options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-options.d.ts","sourceRoot":"","sources":["../src/shared-options.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;;EAMxB,CAAC"}
|
package/dist/shared-options.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { object } from '@optique/core/constructs';
|
|
2
|
-
import { message } from '@optique/core/message';
|
|
3
|
-
import { optional } from '@optique/core/modifiers';
|
|
4
|
-
import { option } from '@optique/core/primitives';
|
|
5
|
-
import { path as pathParser } from '@optique/run/valueparser';
|
|
6
|
-
export const sharedOptions = object(`Global options`, {
|
|
7
|
-
config: optional(option('-c', '--config', pathParser({ metavar: 'CONFIG' }), {
|
|
8
|
-
description: message `path to the lexicon configuration file. defaults to searching for lex.config.js or lex.config.ts in the current directory.`,
|
|
9
|
-
})),
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=shared-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-options.js","sourceRoot":"","sources":["../src/shared-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE;IACrD,MAAM,EAAE,QAAQ,CACf,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE;QAC3D,WAAW,EAAE,OAAO,CAAA,4HAA4H;KAChJ,CAAC,CACF;CACD,CAAC,CAAC"}
|
package/src/shared-options.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { object } from '@optique/core/constructs';
|
|
2
|
-
import { message } from '@optique/core/message';
|
|
3
|
-
import { optional } from '@optique/core/modifiers';
|
|
4
|
-
import { option } from '@optique/core/primitives';
|
|
5
|
-
import { path as pathParser } from '@optique/run/valueparser';
|
|
6
|
-
|
|
7
|
-
export const sharedOptions = object(`Global options`, {
|
|
8
|
-
config: optional(
|
|
9
|
-
option('-c', '--config', pathParser({ metavar: 'CONFIG' }), {
|
|
10
|
-
description: message`path to the lexicon configuration file. defaults to searching for lex.config.js or lex.config.ts in the current directory.`,
|
|
11
|
-
}),
|
|
12
|
-
),
|
|
13
|
-
});
|