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

@ronin/cli

Package Overview
Dependencies
Maintainers
0
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ronin/cli - npm Package Compare versions

Comparing version 0.2.35 to 0.2.36-corny-ron-1099-experimental-124

187

dist/index.js

@@ -6,3 +6,2 @@ // src/index.ts

// src/commands/apply.ts
import ora2 from "ora";
import fs6 from "node:fs";

@@ -39,4 +38,27 @@ import path5 from "node:path";

// src/utils/misc.ts
import fs3 from "node:fs";
import path2 from "node:path";
// src/utils/config.ts
import fs2 from "node:fs";
import path from "node:path";
var saveConfig = (config) => {
const configDir = path.join(process.cwd(), ".ronin");
if (!fs2.existsSync(configDir)) {
fs2.mkdirSync(configDir);
}
const configPath = path.join(configDir, "config.json");
let existingConfig = {};
if (fs2.existsSync(configPath)) {
existingConfig = JSON.parse(fs2.readFileSync(configPath, "utf-8"));
}
fs2.writeFileSync(configPath, JSON.stringify({ ...existingConfig, ...config }, null, 2));
};
var readConfig = () => {
const configPath = path.join(process.cwd(), ".ronin", "config.json");
if (!fs2.existsSync(configPath)) {
return {};
}
return JSON.parse(fs2.readFileSync(configPath, "utf-8"));
};

@@ -275,2 +297,3 @@ // src/utils/queries.ts

// src/utils/misc.ts
import { input } from "@inquirer/prompts";
import resolveFrom from "resolve-from";

@@ -295,6 +318,11 @@ var BASE_FLAGS = {

var MODELS_IN_CODE_DIR = "schema";
var MODEL_IN_CODE_PATH = path.resolve(
var MODEL_IN_CODE_RELATIVE_PATH = path2.join(MODELS_IN_CODE_DIR, "index.ts");
var MODEL_IN_CODE_PATH = path2.resolve(
process.cwd(),
readConfig().modelsDir ?? MODEL_IN_CODE_RELATIVE_PATH
);
var MIGRATIONS_PATH = path2.resolve(
process.cwd(),
MODELS_IN_CODE_DIR,
"index.ts"
"migrations"
);

@@ -345,8 +373,16 @@ var RONIN_SCHEMA_TEMP_SUFFIX = "RONIN_TEMP_";

var getModelDefinitions = async (customPath) => {
if (!fs2.existsSync(customPath ?? MODEL_IN_CODE_PATH)) {
spinner.fail("Could not find a model definition file schema/index.ts");
process.exit(1);
let definedPath;
if (!fs3.existsSync(customPath ?? MODEL_IN_CODE_PATH)) {
spinner.fail(`Could not find a model definition file ${MODEL_IN_CODE_RELATIVE_PATH}`);
definedPath = process.env.NODE_ENV !== "test" ? await input({
message: "Enter the path to the model definition file"
}) : MODEL_IN_CODE_RELATIVE_PATH;
if (!fs3.existsSync(definedPath)) {
spinner.fail("There is no migration file at the given path");
process.exit(1);
}
saveConfig({ modelsDir: definedPath });
}
const sortedModels = sortModels(
Object.values(await import(customPath ?? MODEL_IN_CODE_PATH)).filter(
Object.values(await import(definedPath ?? customPath ?? MODEL_IN_CODE_PATH)).filter(
(value) => typeof value === "object" && value !== null && "slug" in value

@@ -718,9 +754,10 @@ )

// src/utils/protocol.ts
import fs5 from "node:fs";
import path4 from "node:path";
// src/utils/format.ts
import fs4 from "node:fs";
import path3 from "node:path";
// src/utils/format.ts
import fs3 from "node:fs";
import path2 from "node:path";
import { format } from "prettier";
import { createFromBuffer } from "@dprint/formatter";
import { getPath } from "@dprint/typescript";
var detectFormatConfig = () => {

@@ -730,6 +767,6 @@ const configFiles = ["biome.json", ".prettierrc.json", ".eslintrc.json", ".prettierrc"];

for (const file of configFiles) {
const configPath = path2.join(cwd, file);
if (fs3.existsSync(configPath)) {
const configPath = path3.join(cwd, file);
if (fs4.existsSync(configPath)) {
try {
const config = JSON.parse(fs3.readFileSync(configPath, "utf8"));
const config = JSON.parse(fs4.readFileSync(configPath, "utf8"));
if (file === "biome.json") {

@@ -741,3 +778,3 @@ return {

semi: config.javascript?.formatter?.semicolons === "always",
configSource: path2.basename(file)
configSource: path3.basename(file)
};

@@ -751,3 +788,3 @@ }

semi: config.rules?.semi?.[0] === "error" || config.rules?.semi?.[0] === 2,
configSource: path2.basename(file)
configSource: path3.basename(file)
};

@@ -760,3 +797,3 @@ }

semi: config.semi ?? true,
configSource: path2.basename(file)
configSource: path3.basename(file)
};

@@ -778,9 +815,16 @@ } catch (err) {

const config = detectFormatConfig();
return format(code, {
parser: "typescript",
useTabs: config.useTabs,
tabWidth: config.tabWidth,
singleQuote: config.singleQuote,
semi: config.semi
const buffer = fs4.readFileSync(getPath());
const formatter = createFromBuffer(buffer);
const formated = formatter.formatText({
filePath: ".migration.ts",
fileText: code,
overrideConfig: {
parser: "typescript",
useTabs: config.useTabs,
tabWidth: config.tabWidth,
singleQuote: config.singleQuote,
semi: config.semi
}
});
return formated;
};

@@ -793,3 +837,3 @@

_roninQueries;
_protocolDir = `${process.cwd()}/schema/.protocols/`;
_protocolDir = MIGRATIONS_PATH;
/**

@@ -876,7 +920,7 @@ * Creates a new Protocol instance.

const targetFile = fileName || (() => {
const files = fs4.readdirSync(this._protocolDir);
const files = fs5.readdirSync(this._protocolDir);
return files.sort().pop() || "migration";
})();
const filePath = path3.resolve(this._protocolDir, targetFile);
if (!fs4.existsSync(filePath)) {
const filePath = path4.resolve(this._protocolDir, targetFile);
if (!fs5.existsSync(filePath)) {
throw new Error(`Migration protocol file ${filePath} does not exist`);

@@ -897,9 +941,9 @@ }

*/
save = async (fileName) => {
save = (fileName) => {
const migrationContent = this.createMigrationProtocol();
const directoryPath = path3.resolve(this._protocolDir);
fs4.mkdirSync(directoryPath, { recursive: true });
fs4.writeFileSync(
path3.join(directoryPath, `${fileName}.ts`),
await formatCode(migrationContent)
const directoryPath = path4.resolve(this._protocolDir);
fs5.mkdirSync(directoryPath, { recursive: true });
fs5.writeFileSync(
path4.join(directoryPath, `${fileName}.ts`),
formatCode(migrationContent)
);

@@ -917,3 +961,3 @@ return this;

const sqlContent = statements.map(({ statement }) => statement).join("\n");
fs4.writeFileSync(`${this._protocolDir}${fileName}.sql`, sqlContent);
fs5.writeFileSync(`${this._protocolDir}/${fileName}.sql`, sqlContent);
};

@@ -936,25 +980,2 @@ /**

// src/utils/config.ts
import fs5 from "node:fs";
import path4 from "node:path";
var saveConfig = (config) => {
const configDir = path4.join(process.cwd(), ".ronin");
if (!fs5.existsSync(configDir)) {
fs5.mkdirSync(configDir);
}
const configPath = path4.join(configDir, "config.json");
let existingConfig = {};
if (fs5.existsSync(configPath)) {
existingConfig = JSON.parse(fs5.readFileSync(configPath, "utf-8"));
}
fs5.writeFileSync(configPath, JSON.stringify({ ...existingConfig, ...config }, null, 2));
};
var readConfig = () => {
const configPath = path4.join(process.cwd(), ".ronin", "config.json");
if (!fs5.existsSync(configPath)) {
return {};
}
return JSON.parse(fs5.readFileSync(configPath, "utf-8"));
};
// src/utils/space.ts

@@ -975,3 +996,3 @@ import { select } from "@inquirer/prompts";

members: {
including: ["space", "account"],
using: ["space", "account"],
with: {

@@ -1029,4 +1050,5 @@ team: null

// src/commands/apply.ts
import { select as select2 } from "@inquirer/prompts";
var apply_default = async (appToken, sessionToken, flags, migrationFilePath) => {
const spinner2 = ora2("Applying migration").start();
const spinner2 = spinner.info("Applying migration");
const packages = await getLocalPackages();

@@ -1043,21 +1065,15 @@ const db = await initializeDatabase(packages);

);
const protocol = await new Protocol(packages).load(migrationFilePath);
const migrations = fs6.readdirSync(MIGRATIONS_PATH);
const migrationPrompt = migrationFilePath ?? await select2({
message: "Which migration do you want to apply?",
choices: migrations.sort((a, b) => b.localeCompare(a)).map((migration) => ({
name: migration,
value: path5.join(MIGRATIONS_PATH, migration)
}))
});
const protocol = await new Protocol(packages).load(migrationPrompt);
const statements = protocol.getSQLStatements(existingModels);
const files = fs6.readdirSync(
path5.join(process.cwd(), MODELS_IN_CODE_DIR, ".protocols")
);
const latestProtocolFile = files.sort().pop() || "migration";
const migrationsPath = path5.join(process.cwd(), MODELS_IN_CODE_DIR, "migrations");
if (!fs6.existsSync(migrationsPath)) {
fs6.mkdirSync(migrationsPath, { recursive: true });
if (!fs6.existsSync(MIGRATIONS_PATH)) {
fs6.mkdirSync(MIGRATIONS_PATH, { recursive: true });
}
fs6.copyFileSync(
migrationFilePath || path5.join(
process.cwd(),
MODELS_IN_CODE_DIR,
".protocols",
path5.basename(latestProtocolFile)
),
path5.join(migrationsPath, path5.basename(latestProtocolFile))
);
await applyMigrationStatements(

@@ -1135,6 +1151,5 @@ appToken ?? sessionToken,

spinner.text = "Writing migration protocol file";
const migrationsDir = path6.join(process.cwd(), MODELS_IN_CODE_DIR, ".protocols");
const nextNum = (() => {
if (!fs7.existsSync(migrationsDir)) return 1;
const files = fs7.readdirSync(migrationsDir);
if (!fs7.existsSync(MIGRATIONS_PATH)) return 1;
const files = fs7.readdirSync(MIGRATIONS_PATH);
const migrationFiles = files.filter((f) => f.startsWith("migration-"));

@@ -1148,3 +1163,3 @@ if (migrationFiles.length === 0) return 1;

await protocol.convertToQueryObjects();
await protocol.save(`migration-${paddedNum}`);
protocol.save(`migration-${paddedNum}`);
if (flags.sql) {

@@ -1180,3 +1195,3 @@ const allModels = [...existingModels, ...definedModels];

import json5 from "json5";
import ora3 from "ora";
import ora2 from "ora";

@@ -1198,3 +1213,3 @@ // src/utils/file.ts

var init_default = async (positionals) => {
const spinner2 = ora3("Initializing project").start();
const spinner2 = ora2("Initializing project").start();
const lastPositional = positionals.at(-1);

@@ -1254,3 +1269,3 @@ const spaceHandle = lastPositional === "init" ? null : lastPositional;

import open from "open";
import ora4 from "ora";
import ora3 from "ora";

@@ -1339,3 +1354,3 @@ // src/utils/session.ts

var logIn = async (appToken, exit = true) => {
const spinner2 = ora4("Logging in").start();
const spinner2 = ora3("Logging in").start();
if (appToken) {

@@ -1465,3 +1480,3 @@ await Promise.all([storeTokenForNPM(appToken), storeTokenForBun(appToken)]);

if (normalizedPositionals.includes("apply")) {
const migrationFilePath = positionals?.[positionals.indexOf("apply") + 1] ? path10.join(process.cwd(), positionals[positionals.indexOf("apply") + 1]) : MODEL_IN_CODE_PATH;
const migrationFilePath = positionals?.[positionals.indexOf("apply") + 1] ? path10.join(process.cwd(), positionals[positionals.indexOf("apply") + 1]) : void 0;
return apply_default(appToken, session?.token, flags, migrationFilePath);

@@ -1468,0 +1483,0 @@ }

{
"name": "@ronin/cli",
"version": "0.2.35",
"version": "0.2.36-corny-ron-1099-experimental-124",
"type": "module",

@@ -31,2 +31,4 @@ "description": "The command-line interface for RONIN.",

"dependencies": {
"@dprint/formatter": "0.4.1",
"@dprint/typescript": "0.93.3",
"@iarna/toml": "2.2.5",

@@ -41,3 +43,2 @@ "@inquirer/prompts": "7.2.3",

"ora": "8.1.1",
"prettier": "3.4.2",
"resolve-from": "5.0.0"

@@ -44,0 +45,0 @@ },

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