@atproto/lex 0.0.0
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/README.md +1287 -0
- package/bin/lex +165 -0
- package/index.d.ts +6 -0
- package/package.json +52 -0
package/bin/lex
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-env node */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
5
|
+
|
|
6
|
+
// This file is referenced by the "bin" field in package.json. Because of that,
|
|
7
|
+
// we need this file to exist on disk even before the project is built, so it is
|
|
8
|
+
// written in plain JS. This allows package managers to properly link the CLI
|
|
9
|
+
// command when the monorepo is being setup (during initial "pnpm install").
|
|
10
|
+
|
|
11
|
+
const yargs = require('yargs')
|
|
12
|
+
const { hideBin } = require('yargs/helpers')
|
|
13
|
+
const { build } = require('@atproto/lex-builder')
|
|
14
|
+
const { install } = require('@atproto/lex-installer')
|
|
15
|
+
|
|
16
|
+
yargs(hideBin(process.argv))
|
|
17
|
+
.strict()
|
|
18
|
+
.command(
|
|
19
|
+
['build', 'b'],
|
|
20
|
+
'Generate TypeScript lexicon schema files from JSON lexicon definitions',
|
|
21
|
+
(yargs) => {
|
|
22
|
+
return yargs.strict().options({
|
|
23
|
+
lexicons: {
|
|
24
|
+
array: true,
|
|
25
|
+
type: 'string',
|
|
26
|
+
demandOption: true,
|
|
27
|
+
default: './lexicons',
|
|
28
|
+
describe: 'directory containing lexicon JSON files',
|
|
29
|
+
},
|
|
30
|
+
out: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
demandOption: true,
|
|
33
|
+
default: './src/lexicons',
|
|
34
|
+
describe: 'output directory for generated TS files',
|
|
35
|
+
},
|
|
36
|
+
clear: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
default: false,
|
|
39
|
+
describe: 'clear output directory before generating files',
|
|
40
|
+
},
|
|
41
|
+
override: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: false,
|
|
44
|
+
describe: 'override existing files (has no effect with --clear)',
|
|
45
|
+
},
|
|
46
|
+
pretty: {
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
default: true,
|
|
49
|
+
describe: 'run prettier on generated files',
|
|
50
|
+
},
|
|
51
|
+
'ignore-errors': {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: false,
|
|
54
|
+
describe: 'how to handle errors when processing input files',
|
|
55
|
+
},
|
|
56
|
+
'pure-annotations': {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
default: false,
|
|
59
|
+
describe:
|
|
60
|
+
'adds `/*#__PURE__*/` annotations for tree-shaking tools. Set this to true if you are using generated lexicons in a library.',
|
|
61
|
+
},
|
|
62
|
+
exclude: {
|
|
63
|
+
array: true,
|
|
64
|
+
type: 'string',
|
|
65
|
+
describe:
|
|
66
|
+
'list of strings or regex patterns to exclude lexicon documents by their IDs',
|
|
67
|
+
},
|
|
68
|
+
include: {
|
|
69
|
+
array: true,
|
|
70
|
+
type: 'string',
|
|
71
|
+
describe:
|
|
72
|
+
'list of strings or regex patterns to include lexicon documents by their IDs',
|
|
73
|
+
},
|
|
74
|
+
lib: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
default: '@atproto/lex',
|
|
77
|
+
describe:
|
|
78
|
+
'package name of the library to import the lex schema utility "l" from',
|
|
79
|
+
},
|
|
80
|
+
allowLegacyBlobs: {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
default: false,
|
|
83
|
+
describe:
|
|
84
|
+
'allow generating schemas that accept legacy blob references (disabled by default; enabling this might cause compatibility issues with records created a long time ago)',
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
},
|
|
88
|
+
async (argv) => {
|
|
89
|
+
await build(argv)
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
.command(
|
|
93
|
+
['install [nsid..]', 'i [nsid..]'],
|
|
94
|
+
'Fetch and install lexicon documents',
|
|
95
|
+
(yargs) => {
|
|
96
|
+
return yargs.strict().options({
|
|
97
|
+
manifest: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
default: './lexicons.json',
|
|
100
|
+
describe: 'path to lexicons.json manifest file',
|
|
101
|
+
},
|
|
102
|
+
save: {
|
|
103
|
+
alias: 's',
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
default: true,
|
|
106
|
+
describe:
|
|
107
|
+
'Updates lexicons.json with installed lexicons (use --no-save to disable)',
|
|
108
|
+
},
|
|
109
|
+
build: {
|
|
110
|
+
type: 'boolean',
|
|
111
|
+
default: true,
|
|
112
|
+
describe:
|
|
113
|
+
'automatically build TypeScript lexicon schema files after installation (use --no-build to disable)',
|
|
114
|
+
},
|
|
115
|
+
update: {
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
default: false,
|
|
118
|
+
describe:
|
|
119
|
+
'update all installed lexicons to their latest versions by re-resolving and re-installing them',
|
|
120
|
+
},
|
|
121
|
+
ci: {
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
default: false,
|
|
124
|
+
describe:
|
|
125
|
+
'error if the installed lexicons do not match the CIDs in the lexicons.json manifest',
|
|
126
|
+
},
|
|
127
|
+
lexicons: {
|
|
128
|
+
array: true,
|
|
129
|
+
type: 'string',
|
|
130
|
+
demandOption: true,
|
|
131
|
+
default: './lexicons',
|
|
132
|
+
describe: 'directory containing lexicon JSON files',
|
|
133
|
+
},
|
|
134
|
+
out: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
demandOption: true,
|
|
137
|
+
default: './src/lexicons',
|
|
138
|
+
describe: 'output directory for generated TS files',
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
async (argv) => {
|
|
143
|
+
await install({
|
|
144
|
+
add: argv.nsid,
|
|
145
|
+
save: argv.save,
|
|
146
|
+
ci: argv.ci,
|
|
147
|
+
update: argv.update,
|
|
148
|
+
lexicons: argv.lexicons,
|
|
149
|
+
manifest: argv.manifest,
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
if (argv.build) {
|
|
153
|
+
await build({
|
|
154
|
+
lexicons: argv.lexicons,
|
|
155
|
+
out: argv.out,
|
|
156
|
+
clear: true,
|
|
157
|
+
pretty: true,
|
|
158
|
+
pureAnnotations: true,
|
|
159
|
+
ignoreErrors: false,
|
|
160
|
+
lib: '@atproto/lex',
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
.parseAsync()
|
package/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atproto/lex",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Lexicon tooling for AT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"atproto",
|
|
8
|
+
"lexicon",
|
|
9
|
+
"lex"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://atproto.com",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/bluesky-social/atproto",
|
|
15
|
+
"directory": "packages/lex/lex"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"./index.js",
|
|
19
|
+
"./index.d.ts",
|
|
20
|
+
"./bin"
|
|
21
|
+
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"ts-lex": "./bin/lex",
|
|
24
|
+
"lex": "./bin/lex"
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./index.js",
|
|
28
|
+
"types": "./index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"browser": "./index.mjs",
|
|
32
|
+
"import": "./index.mjs",
|
|
33
|
+
"require": "./index.cjs",
|
|
34
|
+
"types": "./index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@atproto/lex-builder": "workspace:*",
|
|
39
|
+
"@atproto/lex-client": "workspace:*",
|
|
40
|
+
"@atproto/lex-installer": "workspace:*",
|
|
41
|
+
"@atproto/lex-schema": "workspace:*",
|
|
42
|
+
"yargs": "^17.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/yargs": "^17.0.33",
|
|
46
|
+
"jest": "^28.1.2"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "./bin/lex build --clear --lexicons ./lexicons --out ./tests/lexicons -- ignore additional npm args",
|
|
50
|
+
"test": "jest"
|
|
51
|
+
}
|
|
52
|
+
}
|