Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zenstack

Package Overview
Dependencies
Maintainers
1
Versions
308
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zenstack - npm Package Compare versions

Comparing version 0.1.42 to 0.1.45

out/utils/exec-utils.js

2

out/cli/cli-util.js

@@ -25,3 +25,3 @@ "use strict";

if (!extensions.includes(path_1.default.extname(fileName))) {
console.error(colors_1.default.yellow(`Please choose a file with one of these extensions: ${extensions}.`));
console.error(colors_1.default.yellow(`Please choose a file with extension: ${extensions}.`));
process.exit(1);

@@ -28,0 +28,0 @@ }

@@ -11,2 +11,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,28 +21,100 @@ exports.generateAction = void 0;

const cli_util_1 = require("./cli-util");
const types_1 = require("../generator/types");
const generator_1 = require("../generator");
const constants_1 = require("../generator/constants");
const generateAction = (fileName, opts) => __awaiter(void 0, void 0, void 0, function* () {
const colors_1 = __importDefault(require("colors"));
const exec_utils_1 = require("../utils/exec-utils");
const change_case_1 = require("change-case");
const path_1 = __importDefault(require("path"));
const generateAction = (options) => __awaiter(void 0, void 0, void 0, function* () {
const services = (0, zmodel_module_1.createZModelServices)().ZModel;
const model = yield (0, cli_util_1.extractAstNode)(fileName, services);
const model = yield (0, cli_util_1.extractAstNode)(options.schema, services);
const context = {
schema: model,
outDir: opts.destination || './zenstack',
outDir: path_1.default.dirname(options.schema),
// TODO: make this configurable
generatedCodeDir: constants_1.GENERATED_CODE_PATH,
};
yield new generator_1.ZenStackGenerator().generate(context);
try {
yield new generator_1.ZenStackGenerator().generate(context);
}
catch (err) {
if (err instanceof types_1.GeneratorError) {
console.error(colors_1.default.red(err.message));
process.exit(1);
}
}
});
exports.generateAction = generateAction;
function prismaAction(prismaCmd) {
return (options, command) => __awaiter(this, void 0, void 0, function* () {
let optStr = Array.from(Object.entries(options))
.map(([k, v]) => {
let optVal = v;
if (k === 'schema') {
optVal = path_1.default.join(path_1.default.dirname(v), 'schema.prisma');
}
return ('--' +
(0, change_case_1.paramCase)(k) +
(typeof optVal === 'string' ? ` ${optVal}` : ''));
})
.join(' ');
const prismaExec = `npx prisma ${prismaCmd} ${command.name()} ${optStr}`;
console.log(prismaExec);
try {
(0, exec_utils_1.execSync)(prismaExec);
}
catch (_a) {
console.error(colors_1.default.red('Prisma command failed to execute. See errors above.'));
process.exit(1);
}
});
}
function default_1() {
const program = new commander_1.Command();
const program = new commander_1.Command('zenstack');
program.version(require('../../package.json').version, '-v --version', 'display CLI version');
const schemaExtensions = module_1.ZModelLanguageMetaData.fileExtensions.join(', ');
program
// eslint-disable-next-line @typescript-eslint/no-var-requires
.version(require('../../package.json').version);
const fileExtensions = module_1.ZModelLanguageMetaData.fileExtensions.join(', ');
.description(`${colors_1.default.bold.blue('ζ')} ZenStack simplifies fullstack development by generating backend services and Typescript clients from a data model.\n\nDocumentation: https://zenstack.dev/doc.`)
.showHelpAfterError()
.showSuggestionAfterError();
const schemaOption = new commander_1.Option('--schema <file>', `schema file (with extension ${schemaExtensions})`).default('./zenstack/schema.zmodel');
program
.command('generate')
.argument('<file>', `source file (possible file extensions: ${fileExtensions})`)
.option('-d, --destination <dir>', 'destination directory of generating')
.description('generates JavaScript code that prints "Hello, {name}!" for each greeting in a source file')
.description('generates RESTful API and Typescript client for your data model')
.addOption(schemaOption)
.action(exports.generateAction);
const migrate = program
.command('migrate')
.description(`wraps Prisma's ${colors_1.default.cyan('migrate')} command`);
migrate
.command('dev')
.description(`alias for ${colors_1.default.cyan('prisma migrate dev')}\nCreate a migration, apply it to the database, generate db client.`)
.addOption(schemaOption)
.option('--create-only', 'Create a migration without applying it')
.action(prismaAction('migrate'));
migrate
.command('reset')
.description(`alias for ${colors_1.default.cyan('prisma migrate reset')}\nReset your database and apply all migrations.`)
.addOption(schemaOption)
.option('--force', 'Skip the confirmation prompt')
.action(prismaAction('migrate'));
migrate
.command('deploy')
.description(`alias for ${colors_1.default.cyan('prisma migrate deploy')}\nApply pending migrations to the database in production/staging.`)
.addOption(schemaOption)
.action(prismaAction('migrate'));
migrate
.command('status')
.description(`alias for ${colors_1.default.cyan('prisma migrate status')}\nCheck the status of migrations in the production/staging database.`)
.addOption(schemaOption)
.action(prismaAction('migrate'));
const db = program
.command('db')
.description(`wraps Prisma's ${colors_1.default.cyan('db')} command`);
db.command('push')
.description(`alias for ${colors_1.default.cyan('prisma db push')}\nPush the Prisma schema state to the database.`)
.addOption(schemaOption)
.option('--accept-data-loss', 'Ignore data loss warnings')
.action(prismaAction('db'));
program.parse(process.argv);

@@ -46,0 +121,0 @@ }

@@ -39,2 +39,3 @@ "use strict";

exports.ZenStackGenerator = void 0;
const types_1 = require("./types");
const fs = __importStar(require("fs"));

@@ -47,3 +48,3 @@ const colors_1 = __importDefault(require("colors"));

const path_1 = __importDefault(require("path"));
const child_process_1 = require("child_process");
const exec_utils_1 = require("../utils/exec-utils");
class ZenStackGenerator {

@@ -76,3 +77,3 @@ generate(context) {

catch (_a) {
console.warn('Next-auth module is not installed, skipping generating adapter.');
console.warn(colors_1.default.yellow('Next-auth module is not installed, skipping generating adapter.'));
}

@@ -89,7 +90,6 @@ for (const generator of generators) {

try {
(0, child_process_1.execSync)(`npx tsc -p "${path_1.default.join(context.generatedCodeDir, 'tsconfig.json')}"`, { encoding: 'utf-8', stdio: 'inherit' });
(0, exec_utils_1.execSync)(`npx tsc -p "${path_1.default.join(context.generatedCodeDir, 'tsconfig.json')}"`);
}
catch (_b) {
console.error(colors_1.default.red('Something went wrong, generated runtime code failed to compile...'));
return;
throw new types_1.GeneratorError('Something went wrong, generated runtime code failed to compile...\nPlease check errors above.');
}

@@ -96,0 +96,0 @@ console.log(colors_1.default.blue(' ✔️ Typescript source files transpiled'));

@@ -16,3 +16,4 @@ "use strict";

const colors_1 = __importDefault(require("colors"));
const child_process_1 = require("child_process");
const types_1 = require("../types");
const exec_utils_1 = require("../../utils/exec-utils");
const schema_generator_1 = __importDefault(require("./schema-generator"));

@@ -34,3 +35,8 @@ const query_gard_generator_1 = __importDefault(require("./query-gard-generator"));

return __awaiter(this, void 0, void 0, function* () {
(0, child_process_1.execSync)(`npx prisma generate --schema "${schemaFile}"`);
try {
(0, exec_utils_1.execSync)(`npx prisma generate --schema "${schemaFile}"`);
}
catch (_a) {
throw new types_1.GeneratorError(`Failed to generate client code with Prisma. Check errors above for clues.\nThis normally shouldn't happen. Please file an issue at: http://go.zenstack.dev/bug.`);
}
});

@@ -37,0 +43,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "ZenStack CLI and Language Tools",
"version": "0.1.42",
"version": "0.1.45",
"engines": {

@@ -8,0 +8,0 @@ "vscode": "^1.56.0"

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

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