@oicl-lit/cli 0.6.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.
Files changed (52) hide show
  1. package/README.md +69 -0
  2. package/bin/lit.js +28 -0
  3. package/lib/.tsbuildinfo +1 -0
  4. package/lib/command.d.ts +120 -0
  5. package/lib/command.js +10 -0
  6. package/lib/command.js.map +1 -0
  7. package/lib/commands/help.d.ts +8 -0
  8. package/lib/commands/help.js +102 -0
  9. package/lib/commands/help.js.map +1 -0
  10. package/lib/commands/init.d.ts +14 -0
  11. package/lib/commands/init.js +60 -0
  12. package/lib/commands/init.js.map +1 -0
  13. package/lib/commands/labs.d.ts +8 -0
  14. package/lib/commands/labs.js +58 -0
  15. package/lib/commands/labs.js.map +1 -0
  16. package/lib/commands/localize.d.ts +7 -0
  17. package/lib/commands/localize.js +13 -0
  18. package/lib/commands/localize.js.map +1 -0
  19. package/lib/console.d.ts +17 -0
  20. package/lib/console.js +37 -0
  21. package/lib/console.js.map +1 -0
  22. package/lib/generate/generate.d.ts +14 -0
  23. package/lib/generate/generate.js +140 -0
  24. package/lib/generate/generate.js.map +1 -0
  25. package/lib/init/element-starter/index.d.ts +11 -0
  26. package/lib/init/element-starter/index.js +39 -0
  27. package/lib/init/element-starter/index.js.map +1 -0
  28. package/lib/init/element-starter/templates/demo/index.html.d.ts +7 -0
  29. package/lib/init/element-starter/templates/demo/index.html.js +23 -0
  30. package/lib/init/element-starter/templates/demo/index.html.js.map +1 -0
  31. package/lib/init/element-starter/templates/gitignore.d.ts +8 -0
  32. package/lib/init/element-starter/templates/gitignore.js +14 -0
  33. package/lib/init/element-starter/templates/gitignore.js.map +1 -0
  34. package/lib/init/element-starter/templates/lib/element.d.ts +8 -0
  35. package/lib/init/element-starter/templates/lib/element.js +86 -0
  36. package/lib/init/element-starter/templates/lib/element.js.map +1 -0
  37. package/lib/init/element-starter/templates/package.json.d.ts +8 -0
  38. package/lib/init/element-starter/templates/package.json.js +48 -0
  39. package/lib/init/element-starter/templates/package.json.js.map +1 -0
  40. package/lib/init/element-starter/templates/tsconfig.json.d.ts +7 -0
  41. package/lib/init/element-starter/templates/tsconfig.json.js +29 -0
  42. package/lib/init/element-starter/templates/tsconfig.json.js.map +1 -0
  43. package/lib/lit-cli.d.ts +40 -0
  44. package/lib/lit-cli.js +266 -0
  45. package/lib/lit-cli.js.map +1 -0
  46. package/lib/lit-version.d.ts +1 -0
  47. package/lib/lit-version.js +2 -0
  48. package/lib/lit-version.js.map +1 -0
  49. package/lib/options.d.ts +18 -0
  50. package/lib/options.js +59 -0
  51. package/lib/options.js.map +1 -0
  52. package/package.json +119 -0
package/lib/lit-cli.js ADDED
@@ -0,0 +1,266 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import commandLineCommands from 'command-line-commands';
7
+ import commandLineArgs from 'command-line-args';
8
+ import { isCommand, } from './command.js';
9
+ import { LitConsole } from './console.js';
10
+ import { globalOptions, mergeOptions } from './options.js';
11
+ import { makeHelpCommand } from './commands/help.js';
12
+ import { localize } from './commands/localize.js';
13
+ import { makeLabsCommand } from './commands/labs.js';
14
+ import { makeInitCommand } from './commands/init.js';
15
+ import { createRequire } from 'module';
16
+ import * as childProcess from 'child_process';
17
+ export class LitCli {
18
+ constructor(args, options) {
19
+ this.commands = new Map();
20
+ this.skipPermissions = false;
21
+ this.cwd = options.cwd;
22
+ this.stdin = options.stdin ?? process.stdin;
23
+ this.console =
24
+ options?.console ?? new LitConsole(process.stdout, process.stderr);
25
+ this.console.logLevel = 'info';
26
+ // If the "--quiet"/"-q" flag is ever present, set our global logging
27
+ // to quiet mode. Also set the level on the logger we've already created.
28
+ if (args.indexOf('--quiet') > -1 || args.indexOf('-q') > -1) {
29
+ this.console.logLevel = 'error';
30
+ }
31
+ // If the "--verbose"/"-v" flag is ever present, set our global logging
32
+ // to verbose mode. Also set the level on the logger we've already created.
33
+ if (args.indexOf('--verbose') > -1 || args.indexOf('-v') > -1) {
34
+ this.console.logLevel = 'debug';
35
+ }
36
+ // If the "--autoinstall" flag is ever present, it will automatically
37
+ // install commands that are not installed without asking for permission.
38
+ if (args.indexOf('--autoinstall') > -1) {
39
+ this.skipPermissions = true;
40
+ }
41
+ this.args = args;
42
+ this.console.debug('got args:', { args: args });
43
+ this.addCommand(localize);
44
+ this.addCommand(makeLabsCommand(this));
45
+ this.addCommand(makeHelpCommand(this));
46
+ this.addCommand(makeInitCommand(this));
47
+ }
48
+ addCommand(command) {
49
+ this.console.debug('adding command', command.name);
50
+ this.commands.set(command.name, command);
51
+ command.aliases?.forEach((alias) => {
52
+ this.console.debug('adding alias', alias);
53
+ this.commands.set(alias, command);
54
+ });
55
+ }
56
+ async run() {
57
+ const helpCommand = this.commands.get('help');
58
+ if (helpCommand?.kind !== 'resolved') {
59
+ throw new Error(`Internal error: help command not found`);
60
+ }
61
+ this.console.debug('running...');
62
+ // If the "--version" flag is ever present, just print
63
+ // the current version. Useful for globally installed CLIs.
64
+ if (this.args.includes('--version')) {
65
+ const require = createRequire(import.meta.url);
66
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
67
+ console.log(require('../package.json').version);
68
+ return;
69
+ }
70
+ const result = await this.getCommand(this.commands, this.args);
71
+ if ('invalidCommand' in result) {
72
+ return await helpCommand.run({ command: [result.invalidCommand] }, this.console);
73
+ }
74
+ else if ('commandNotInstalled' in result) {
75
+ this.console.error(`Command not installed.`);
76
+ return { exitCode: 1 };
77
+ }
78
+ else {
79
+ const commandName = result.commandName;
80
+ const command = result.command;
81
+ const commandArgs = result.argv;
82
+ this.console.debug(`command '${commandName}' found, parsing command args:`, { args: commandArgs });
83
+ const commandDefinitions = mergeOptions([
84
+ command.options ?? [],
85
+ globalOptions,
86
+ ]);
87
+ const commandOptions = commandLineArgs(commandDefinitions, {
88
+ argv: commandArgs,
89
+ });
90
+ this.console.debug(`command options parsed from args:`, commandOptions);
91
+ // Help is a special argument for displaying help for the given command.
92
+ // If found, run the help command instead, with the given command name as
93
+ // an option.
94
+ if (commandOptions['help']) {
95
+ this.console.debug(`'--help' option found, running 'help' for given command...`);
96
+ return await helpCommand.run({ command: commandName }, this.console);
97
+ }
98
+ this.console.debug('Running command...');
99
+ return await command.run(commandOptions, this.console);
100
+ }
101
+ }
102
+ async getCommand(commands, args, parentCommandNames = []) {
103
+ try {
104
+ const parsedArgs = commandLineCommands([...commands.keys()], [...args]);
105
+ const commandName = parsedArgs.command;
106
+ let command = commandName && commands.get(commandName);
107
+ if (!commandName || command == null || command == '') {
108
+ return { invalidCommand: commandName ?? 'unknown command' };
109
+ }
110
+ const maybeCommand = await this.resolveCommandAndMaybeInstallNeededDeps(command);
111
+ if (maybeCommand === undefined) {
112
+ return { commandNotInstalled: true };
113
+ }
114
+ command = maybeCommand;
115
+ if (command.subcommands !== undefined && parsedArgs.argv.length > 0) {
116
+ const subcommands = new Map(command.subcommands.map((c) => [c.name, c]));
117
+ return this.getCommand(subcommands, parsedArgs.argv, [
118
+ ...parentCommandNames,
119
+ commandName,
120
+ ]);
121
+ }
122
+ return {
123
+ commandName: [...parentCommandNames, commandName].join(' '),
124
+ command,
125
+ argv: parsedArgs.argv,
126
+ };
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ }
129
+ catch (error) {
130
+ // We need a valid command name to do anything. If the given
131
+ // command is invalid, run the generalized help command.
132
+ if (error instanceof Error && error.name === 'INVALID_COMMAND') {
133
+ return {
134
+ invalidCommand: [
135
+ ...parentCommandNames,
136
+ error.command,
137
+ ].join(' '),
138
+ };
139
+ }
140
+ // If an unexpected error occurred, propagate it
141
+ throw error;
142
+ }
143
+ }
144
+ resolveImportForReference(reference) {
145
+ try {
146
+ // Must prepend with `file://` so that windows absolute paths are valid
147
+ // ESM import specifiers
148
+ return ('file://' +
149
+ createRequire(this.cwd).resolve(reference.importSpecifier, {
150
+ paths: [this.cwd],
151
+ }));
152
+ }
153
+ catch (e) {
154
+ if (e?.code === 'MODULE_NOT_FOUND') {
155
+ return undefined;
156
+ }
157
+ throw e;
158
+ }
159
+ }
160
+ async loadCommandFromPath(reference, path) {
161
+ const mod = (await import(path));
162
+ if (mod.getCommand == null) {
163
+ throw new Error(`Expected file at ${path} to export a function named 'getCommand'`);
164
+ }
165
+ const maybeCommand = await mod.getCommand({
166
+ requestedCommand: reference.name,
167
+ });
168
+ if (!isCommand(maybeCommand)) {
169
+ throw new Error(`Expected getCommand function at ${path} to return an object that looks like a Command.`);
170
+ }
171
+ return maybeCommand;
172
+ }
173
+ async resolveCommandAsMuchAsPossible(reference) {
174
+ if (reference.kind === 'resolved') {
175
+ return reference;
176
+ }
177
+ const resolvedPackageLocation = this.resolveImportForReference(reference);
178
+ if (resolvedPackageLocation === undefined) {
179
+ return reference;
180
+ }
181
+ const command = await this.loadCommandFromPath(reference, resolvedPackageLocation);
182
+ if (command.kind === 'reference') {
183
+ return this.resolveCommandAsMuchAsPossible(command);
184
+ }
185
+ return command;
186
+ }
187
+ async resolveCommandAndMaybeInstallNeededDeps(maybeReference) {
188
+ if (maybeReference.kind === 'resolved') {
189
+ return maybeReference;
190
+ }
191
+ const reference = maybeReference;
192
+ let resolvedPackageLocation = this.resolveImportForReference(reference);
193
+ if (resolvedPackageLocation === undefined) {
194
+ const installed = await this.installDepWithPermission(reference);
195
+ if (!installed) {
196
+ return undefined;
197
+ }
198
+ resolvedPackageLocation = this.resolveImportForReference(reference);
199
+ if (resolvedPackageLocation === undefined) {
200
+ throw new Error(`Internal error: could not resolve command after what looked like a successful installation.`);
201
+ }
202
+ }
203
+ const command = await this.loadCommandFromPath(reference, resolvedPackageLocation);
204
+ if (command.kind === 'reference') {
205
+ return this.resolveCommandAndMaybeInstallNeededDeps(command);
206
+ }
207
+ return command;
208
+ }
209
+ async installDepWithPermission(reference) {
210
+ const havePermission = this.skipPermissions
211
+ ? true
212
+ : await this.getPermissionToInstall(reference);
213
+ if (!havePermission) {
214
+ return false;
215
+ }
216
+ const installFrom = reference.installFrom ?? reference.importSpecifier;
217
+ this.console.log(`Installing ${installFrom}...`);
218
+ const child = childProcess.spawn('npm', ['install', '--save-dev', installFrom], {
219
+ cwd: this.cwd,
220
+ stdio: [process.stdin, 'pipe', 'pipe'],
221
+ shell: true,
222
+ });
223
+ (async () => {
224
+ for await (const line of child.stdout) {
225
+ this.console.log(line.toString());
226
+ }
227
+ })();
228
+ (async () => {
229
+ for await (const line of child.stderr) {
230
+ this.console.error(line.toString());
231
+ }
232
+ })();
233
+ const succeeded = await new Promise((resolve) => {
234
+ child.on('exit', (code) => {
235
+ resolve(code === 0);
236
+ });
237
+ child.on('error', (err) => {
238
+ this.console.error(`Error installing dependency: ${err}`);
239
+ resolve(false);
240
+ });
241
+ });
242
+ return succeeded;
243
+ }
244
+ async getPermissionToInstall(reference) {
245
+ this.console.log(`The command ${reference.name} is not installed.
246
+ Run 'npm install --save-dev ${reference.installFrom ?? reference.importSpecifier}'? [Y/n]`);
247
+ // read a line from this.stdin
248
+ const line = await new Promise((resolve) => {
249
+ const closeHandler = (data) => {
250
+ if (data) {
251
+ resolve(String(data));
252
+ }
253
+ else {
254
+ resolve('');
255
+ }
256
+ };
257
+ this.stdin.once('close', closeHandler);
258
+ this.stdin.once('data', (data) => {
259
+ resolve(String(data));
260
+ this.stdin.removeListener('close', closeHandler);
261
+ });
262
+ });
263
+ return line === '\n' || line.trim().toLowerCase() === 'y';
264
+ }
265
+ }
266
+ //# sourceMappingURL=lit-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-cli.js","sourceRoot":"","sources":["../src/lib/lit-cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,SAAS,GAIV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,aAAa,EAAE,Y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O,KAAK,CAAC,sBAAsB,CAClC,SAA6B;QAE7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,CAAC,IAAI;8BAE5C,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,eACrC,UAAU,CAAC,CAAC;QACZ,8BAA8B;QAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;YACjD,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,EAAE;gBACrC,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxB,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,EAAE,CAAC,CAAC;gBACd,CAAC;YACH,CAAC,CAAC;YACF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAa,EAAE,EAAE;gBACxC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC;IAC5D,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const litVersion = "3.3.3";
@@ -0,0 +1,2 @@
1
+ export const litVersion = '3.3.3';
2
+ //# sourceMappingURL=lit-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-version.js","sourceRoot":"","sources":["../src/lib/lit-version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { OptionDefinition } from 'command-line-usage';
7
+ export type { OptionDefinition } from 'command-line-usage';
8
+ export declare const globalOptions: OptionDefinition[];
9
+ /**
10
+ * Performs a simple merge of multiple arguments lists. Does not mutate given
11
+ * arguments lists or arguments.
12
+ *
13
+ * This doesn't perform any validation of duplicate arguments, multiple
14
+ * defaults, etc., because by the time this function is run, the user can't do
15
+ * anything about it. Validation of command and global arguments should be done
16
+ * in tests, not on users machines.
17
+ */
18
+ export declare function mergeOptions(optionsLists: OptionDefinition[][]): OptionDefinition[];
package/lib/options.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ export const globalOptions = [
7
+ {
8
+ name: 'verbose',
9
+ description: 'turn on debugging output',
10
+ type: Boolean,
11
+ alias: 'v',
12
+ // group: 'global',
13
+ },
14
+ {
15
+ name: 'help',
16
+ description: 'print out helpful usage information',
17
+ type: Boolean,
18
+ alias: 'h',
19
+ // group: 'global',
20
+ },
21
+ {
22
+ name: 'quiet',
23
+ description: 'silence output',
24
+ type: Boolean,
25
+ alias: 'q',
26
+ // group: 'global',
27
+ },
28
+ {
29
+ name: 'version',
30
+ description: 'Print version info.',
31
+ type: Boolean,
32
+ // group: 'global',
33
+ },
34
+ {
35
+ name: 'autoinstall',
36
+ description: 'automatically install commands that are not installed without asking for permission',
37
+ type: Boolean,
38
+ // group: 'global',
39
+ },
40
+ ];
41
+ /**
42
+ * Performs a simple merge of multiple arguments lists. Does not mutate given
43
+ * arguments lists or arguments.
44
+ *
45
+ * This doesn't perform any validation of duplicate arguments, multiple
46
+ * defaults, etc., because by the time this function is run, the user can't do
47
+ * anything about it. Validation of command and global arguments should be done
48
+ * in tests, not on users machines.
49
+ */
50
+ export function mergeOptions(optionsLists) {
51
+ const optionsByName = new Map();
52
+ for (const opts of optionsLists) {
53
+ for (const option of opts) {
54
+ optionsByName.set(option.name, Object.assign({}, optionsByName.get(option.name), option));
55
+ }
56
+ }
57
+ return Array.from(optionsByName.values());
58
+ }
59
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,CAAC,MAAM,aAAa,GAAuB;IAC/C;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,0BAA0B;QACvC,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,GAAG;QACV,mBAAmB;KACpB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,qCAAqC;QAClD,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,GAAG;QACV,mBAAmB;KACpB;IACD;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,gBAAgB;QAC7B,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,GAAG;QACV,mBAAmB;KACpB;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,OAAO;QACb,mBAAmB;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,qFAAqF;QACvF,IAAI,EAAE,OAAO;QACb,mBAAmB;KACpB;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,YAAkC;IAElC,MAAM,aAAa,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;YAC1B,aAAa,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,119 @@
1
+ {
2
+ "name": "@oicl-lit/cli",
3
+ "description": "Tooling for Lit development",
4
+ "version": "0.6.6",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "author": "Google LLC",
9
+ "license": "BSD-3-Clause",
10
+ "bin": {
11
+ "lit": "./bin/lit.js"
12
+ },
13
+ "bugs": "https://github.com/lit/lit/issues",
14
+ "type": "module",
15
+ "main": "lib/index.js",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/lit/lit.git",
19
+ "directory": "packages/labs/cli"
20
+ },
21
+ "scripts": {
22
+ "build": "wireit",
23
+ "test": "wireit",
24
+ "test:compile": "wireit",
25
+ "test:actual": "wireit",
26
+ "build:deps": "wireit"
27
+ },
28
+ "wireit": {
29
+ "build": {
30
+ "command": "tsc --skipLibCheck || echo ''",
31
+ "#comment": "This never fails and always emits output so that we can run tests of code that doesn't type check",
32
+ "clean": "if-file-deleted",
33
+ "dependencies": [
34
+ "build:deps"
35
+ ],
36
+ "files": [
37
+ "tsconfig.json",
38
+ "src/**/*"
39
+ ],
40
+ "output": [
41
+ "lib",
42
+ "test",
43
+ "index.{js,js.map,d.ts}"
44
+ ]
45
+ },
46
+ "build:deps": {
47
+ "dependencies": [
48
+ "../cli-localize:build",
49
+ "../../tests:build",
50
+ "../analyzer:build",
51
+ "../gen-wrapper-react:build",
52
+ "../gen-wrapper-vue:build",
53
+ "../gen-wrapper-angular:build",
54
+ "../gen-manifest:build",
55
+ "../gen-utils:build"
56
+ ]
57
+ },
58
+ "test": {
59
+ "dependencies": [
60
+ "test:compile",
61
+ "test:actual"
62
+ ]
63
+ },
64
+ "test:compile": {
65
+ "dependencies": [
66
+ "build:deps"
67
+ ],
68
+ "command": "tsc --pretty --noEmit",
69
+ "files": [
70
+ "tsconfig.json",
71
+ "src/**/*",
72
+ "test-goldens/**/*"
73
+ ],
74
+ "output": []
75
+ },
76
+ "test:actual": {
77
+ "#comment": "The quotes around the file regex must be double quotes on windows!",
78
+ "command": "cross-env NODE_OPTIONS=--enable-source-maps uvu test \"_test\\.js$\"",
79
+ "dependencies": [
80
+ "build"
81
+ ],
82
+ "files": [],
83
+ "output": []
84
+ }
85
+ },
86
+ "dependencies": {
87
+ "@oicl-lit/analyzer": "^0.14.0",
88
+ "@oicl-lit/gen-utils": "^0.3.0",
89
+ "@lit/localize-tools": "^0.8.0",
90
+ "chalk": "^5.0.1",
91
+ "command-line-args": "^5.2.1",
92
+ "command-line-commands": "^3.0.2",
93
+ "command-line-usage": "^6.1.1",
94
+ "tslib": "^2.0.3",
95
+ "typescript": "~5.9.0"
96
+ },
97
+ "devDependencies": {
98
+ "@lit-internal/tests": "^0.0.1",
99
+ "@types/command-line-args": "^5.2.0",
100
+ "@types/command-line-commands": "^2.0.1",
101
+ "@types/command-line-usage": "^5.0.2"
102
+ },
103
+ "engines": {
104
+ "node": ">=14.8.0"
105
+ },
106
+ "files": [
107
+ "bin",
108
+ "lib",
109
+ "npm-shrinkwrap.json"
110
+ ],
111
+ "exports": "./index.js",
112
+ "homepage": "https://github.com/lit/lit",
113
+ "keywords": [
114
+ "lit",
115
+ "lit-html",
116
+ "lit-element",
117
+ "LitElement"
118
+ ]
119
+ }