Socket
Socket
Sign inDemoInstall

@lit-labs/cli

Package Overview
Dependencies
62
Maintainers
10
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

10

lib/commands/labs.js

@@ -38,6 +38,12 @@ /**

},
{
name: 'exclude',
multiple: true,
defaultValue: [],
description: 'Glob of source files to exclude from analysis.',
},
],
async run({ package: packages, framework: frameworks, manifest, out: outDir, }, console) {
async run({ package: packages, framework: frameworks, manifest, out: outDir, exclude, }, console) {
const gen = await import('../generate/generate.js');
await gen.run({ cli, packages, frameworks, manifest, outDir }, console);
await gen.run({ cli, packages, frameworks, manifest, outDir, exclude }, console);
},

@@ -44,0 +50,0 @@ },

@@ -8,3 +8,3 @@ /**

import { LitCli } from '../lit-cli.js';
export declare const run: ({ cli, packages, frameworks: frameworkNames, manifest, outDir, }: {
export declare const run: ({ cli, packages, frameworks: frameworkNames, manifest, exclude, outDir, }: {
packages: string[];

@@ -14,3 +14,4 @@ frameworks: string[];

outDir: string;
exclude?: string[] | undefined;
cli: LitCli;
}, console: Console) => Promise<void>;
}, console: Console) => Promise<1 | undefined>;

120

lib/generate/generate.js

@@ -34,65 +34,71 @@ /**

};
export const run = async ({ cli, packages, frameworks: frameworkNames, manifest, outDir, }, console) => {
for (const packageRoot of packages) {
// Ensure separators in input paths are normalized and resolved to absolute
const root = path.normalize(path.resolve(packageRoot));
const out = path.normalize(path.resolve(outDir));
const analyzer = createPackageAnalyzer(root);
const pkg = analyzer.getPackage();
if (!pkg.packageJson.name) {
throw new Error(`Package at '${packageRoot}' did not have a name in package.json. The 'gen' command requires that packages have a name.`);
}
const generatorReferences = [];
for (const name of (frameworkNames ?? [])) {
const framework = frameworkCommands[name];
if (framework == null) {
throw new Error(`No generator exists for framework '${framework}'`);
export const run = async ({ cli, packages, frameworks: frameworkNames, manifest, exclude, outDir, }, console) => {
try {
for (const packageRoot of packages) {
// Ensure separators in input paths are normalized and resolved to absolute
const root = path.normalize(path.resolve(packageRoot));
const out = path.normalize(path.resolve(outDir));
const analyzer = createPackageAnalyzer(root, { exclude });
const pkg = analyzer.getPackage();
if (!pkg.packageJson.name) {
throw new Error(`Package at '${packageRoot}' did not have a name in package.json. The 'gen' command requires that packages have a name.`);
}
generatorReferences.push(framework);
}
if (manifest) {
generatorReferences.push(manifestCommand);
}
// Optimistically try to import all generators in parallel.
// If any aren't installed we need to ask for permission to install it
// below, but in the common happy case this will do all the loading work.
await Promise.all(generatorReferences.map(async (ref) => {
const specifier = cli.resolveImportForReference(ref);
if (specifier != null) {
await import(specifier);
const generatorReferences = [];
for (const name of (frameworkNames ?? [])) {
const framework = frameworkCommands[name];
if (framework == null) {
throw new Error(`No generator exists for framework '${framework}'`);
}
generatorReferences.push(framework);
}
}));
// Now go through one by one and install any as necessary.
// This must be one by one in case we need to ask for permission.
const generators = [];
for (const reference of generatorReferences) {
const resolved = await cli.resolveCommandAndMaybeInstallNeededDeps(reference);
if (resolved == null) {
throw new Error(`Could not load generator for ${reference.name}`);
if (manifest) {
generatorReferences.push(manifestCommand);
}
generators.push(resolved);
// Optimistically try to import all generators in parallel.
// If any aren't installed we need to ask for permission to install it
// below, but in the common happy case this will do all the loading work.
await Promise.all(generatorReferences.map(async (ref) => {
const specifier = cli.resolveImportForReference(ref);
if (specifier != null) {
await import(specifier);
}
}));
// Now go through one by one and install any as necessary.
// This must be one by one in case we need to ask for permission.
const generators = [];
for (const reference of generatorReferences) {
const resolved = await cli.resolveCommandAndMaybeInstallNeededDeps(reference);
if (resolved == null) {
throw new Error(`Could not load generator for ${reference.name}`);
}
generators.push(resolved);
}
const options = {
package: pkg,
};
const results = await Promise.allSettled(generators.map(async (generator) => {
// TODO(kschaaf): Add try/catches around each of these operations and
// throw more contextural errors
await writeFileTree(out, await generator.generate(options, console));
}));
// `allSettled` will swallow errors, so we need to filter them out of
// the results and throw a new error up the stack describing all the errors
// that happened
const errors = results
.map((r, i) => r.status === 'rejected'
? `Error generating '${generators[i].name}' wrapper for package '${packageRoot}': ` +
r.reason.stack ?? r.reason
: '')
.filter((e) => e)
.join('\n');
if (errors.length > 0) {
throw new Error(errors);
}
}
const options = {
package: pkg,
};
const results = await Promise.allSettled(generators.map(async (generator) => {
// TODO(kschaaf): Add try/catches around each of these operations and
// throw more contextural errors
await writeFileTree(out, await generator.generate(options, console));
}));
// `allSettled` will swallow errors, so we need to filter them out of
// the results and throw a new error up the stack describing all the errors
// that happened
const errors = results
.map((r, i) => r.status === 'rejected'
? `Error generating '${generators[i].name}' wrapper for package '${packageRoot}': ` +
r.reason.stack ?? r.reason
: '')
.filter((e) => e)
.join('\n');
if (errors.length > 0) {
throw new Error(errors);
}
}
catch (e) {
console.error(e.message ?? e);
return 1;
}
};
//# sourceMappingURL=generate.js.map

@@ -1,1 +0,1 @@

export declare const litVersion = "2.5.0";
export declare const litVersion = "2.7.0";

@@ -1,2 +0,2 @@

export const litVersion = '2.5.0';
export const litVersion = '2.7.0';
//# sourceMappingURL=lit-version.js.map
{
"name": "@lit-labs/cli",
"description": "Tooling for Lit development",
"version": "0.3.0",
"version": "0.4.0",
"publishConfig": {

@@ -49,2 +49,3 @@ "access": "public"

"../gen-wrapper-vue:build",
"../gen-manifest:build",
"../gen-utils:build"

@@ -82,3 +83,3 @@ ]

"dependencies": {
"@lit-labs/analyzer": "^0.5.0",
"@lit-labs/analyzer": "^0.6.0",
"@lit-labs/gen-utils": "^0.2.0",

@@ -85,0 +86,0 @@ "@lit/localize-tools": "^0.6.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc