New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zenstackhq/sdk

Package Overview
Dependencies
Maintainers
2
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenstackhq/sdk - npm Package Compare versions

Comparing version 1.0.0-alpha.102 to 1.0.0-alpha.110

12

code-gen.d.ts

@@ -1,5 +0,13 @@

import { Project } from 'ts-morph';
import { CompilerOptions, Project } from 'ts-morph';
/**
* Creates a TS code generation project
*/
export declare function createProject(options?: CompilerOptions): Project;
/**
* Persists a TS project to disk.
*/
export declare function saveProject(project: Project): Promise<void>;
/**
* Emit a TS project to JS files.
*/
export declare function emitProject(project: Project, format?: boolean): Promise<void>;
export declare function emitProject(project: Project): Promise<void>;

@@ -15,4 +15,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.emitProject = void 0;
exports.emitProject = exports.saveProject = exports.createProject = void 0;
const prettier_1 = __importDefault(require("prettier"));
const ts_morph_1 = require("ts-morph");
const types_1 = require("./types");
const formatOptions = {

@@ -42,12 +44,42 @@ trailingComma: 'all',

/**
* Creates a TS code generation project
*/
function createProject(options) {
return new ts_morph_1.Project({
compilerOptions: Object.assign({ target: ts_morph_1.ScriptTarget.ES2016, module: ts_morph_1.ModuleKind.CommonJS, esModuleInterop: true, declaration: true, strict: true, skipLibCheck: true, noEmitOnError: true }, options),
});
}
exports.createProject = createProject;
/**
* Persists a TS project to disk.
*/
function saveProject(project) {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.all(project.getSourceFiles().map((sf) => __awaiter(this, void 0, void 0, function* () {
yield formatFile(sf);
})));
yield project.save();
});
}
exports.saveProject = saveProject;
/**
* Emit a TS project to JS files.
*/
function emitProject(project, format = true) {
function emitProject(project) {
return __awaiter(this, void 0, void 0, function* () {
if (format) {
yield Promise.all(project.getSourceFiles().map((sf) => __awaiter(this, void 0, void 0, function* () {
yield formatFile(sf);
})));
const errors = project.getPreEmitDiagnostics().filter((d) => d.getCategory() === ts_morph_1.DiagnosticCategory.Error);
if (errors.length > 0) {
console.error('Error compiling generated code:');
console.error(project.formatDiagnosticsWithColorAndContext(errors.slice(0, 10)));
yield project.save();
throw new types_1.PluginError(`Error compiling generated code`);
}
yield project.emit();
const result = yield project.emit();
const emitErrors = result.getDiagnostics().filter((d) => d.getCategory() === ts_morph_1.DiagnosticCategory.Error);
if (emitErrors.length > 0) {
console.error('Some generated code is not emitted:');
console.error(project.formatDiagnosticsWithColorAndContext(emitErrors.slice(0, 10)));
yield project.save();
throw new types_1.PluginError(`Error emitting generated code`);
}
});

@@ -54,0 +86,0 @@ }

4

package.json
{
"name": "@zenstackhq/sdk",
"version": "1.0.0-alpha.102",
"version": "1.0.0-alpha.110",
"description": "ZenStack plugin development SDK",

@@ -17,3 +17,3 @@ "main": "index.js",

"ts-morph": "^16.0.0",
"@zenstackhq/language": "1.0.0-alpha.102"
"@zenstackhq/language": "1.0.0-alpha.110"
},

@@ -20,0 +20,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc