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

instant-cli

Package Overview
Dependencies
Maintainers
0
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instant-cli - npm Package Compare versions

Comparing version

to
0.17.16-experimental.1

175

dist/index.js

@@ -13,3 +13,3 @@ // @ts-check

import { mkdir, writeFile, readFile } from 'fs/promises';
import { join } from 'path';
import path, { join } from 'path';
import { randomUUID } from 'crypto';

@@ -663,10 +663,10 @@ import jsonDiff from 'json-diff';

}
const prevSchema = yield readLocalSchemaFile();
if (prevSchema) {
const ok = yield promptOk('This will overwrite your local instant.schema file, OK to proceed?');
if (!ok)
const prev = yield readLocalSchemaFile();
if (prev) {
const shouldContinue = yield promptOk('This will overwrite your local instant.schema file, OK to proceed?');
if (!shouldContinue)
return { ok: true };
}
const schemaPath = join(pkgDir, 'instant.schema.ts');
yield writeTypescript(schemaPath, generateSchemaTypescriptFile(prevSchema, pullRes.data.schema, instantModuleName), 'utf-8');
const schemaPath = join(pkgDir, getSchemaPathToWrite(prev === null || prev === void 0 ? void 0 : prev.path));
yield writeTypescript(schemaPath, generateSchemaTypescriptFile(prev === null || prev === void 0 ? void 0 : prev.schema, pullRes.data.schema, instantModuleName), 'utf-8');
console.log('✅ Wrote schema to instant.schema.ts');

@@ -686,8 +686,9 @@ return { ok: true };

return;
if (yield pathExists(join(pkgDir, 'instant.perms.ts'))) {
const ok = yield promptOk('This will overwrite your local instant.perms file, OK to proceed?');
if (!ok)
return;
const prev = yield readLocalPermsFile();
if (prev) {
const shouldContinue = yield promptOk('This will overwrite your local instant.perms file, OK to proceed?');
if (!shouldContinue)
return { ok: true };
}
const permsPath = join(pkgDir, 'instant.perms.ts');
const permsPath = join(pkgDir, getPermsPathToWrite(prev === null || prev === void 0 ? void 0 : prev.path));
yield writeTypescript(permsPath, generatePermsTypescriptFile(pullRes.data.perms || {}, instantModuleName), 'utf-8');

@@ -885,5 +886,6 @@ console.log('✅ Wrote permissions to instant.perms.ts');

return __awaiter(this, void 0, void 0, function* () {
const schema = yield readLocalSchemaFileWithErrorLogging();
if (!schema)
const res = yield readLocalSchemaFileWithErrorLogging();
if (!res)
return { ok: false };
const { schema } = res;
console.log('Planning schema...');

@@ -976,4 +978,4 @@ const planRes = yield fetchJson({

return __awaiter(this, void 0, void 0, function* () {
const perms = yield readLocalPermsFileWithErrorLogging();
if (!perms) {
const res = yield readLocalPermsFileWithErrorLogging();
if (!res) {
return;

@@ -989,3 +991,3 @@ }

return;
const diffedStr = jsonDiff.diffString(prodPerms.data.perms || {}, perms || {});
const diffedStr = jsonDiff.diffString(prodPerms.data.perms || {}, res.perms || {});
if (!diffedStr.length) {

@@ -1006,3 +1008,3 @@ console.log('No perms changes detected. Exiting.');

body: {
code: perms,
code: res.perms,
},

@@ -1158,21 +1160,50 @@ });

}
function getEnvPermsPathWithLogging() {
const path = process.env.INSTANT_PERMS_FILE_PATH;
if (path) {
console.log(`Using INSTANT_PERMS_FILE_PATH=${chalk.green(process.env.INSTANT_PERMS_FILE_PATH)}`);
}
return path;
}
function getPermsReadCandidates() {
const existing = getEnvPermsPathWithLogging();
if (existing)
return [{ files: existing, transform: transformImports }];
return [
{
files: 'instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'src/instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'app/instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
];
}
function getPermsPathToWrite(existingPath) {
if (existingPath)
return existingPath;
if (process.env.INSTANT_PERMS_FILE_PATH) {
return process.env.INSTANT_PERMS_FILE_PATH;
}
return 'instant.perms.ts';
}
function readLocalPermsFile() {
return __awaiter(this, void 0, void 0, function* () {
const { config, sources } = yield loadConfig({
sources: [
// load from `instant.perms.xx`
{
files: 'instant.perms',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
transform: transformImports,
},
],
// if false, the only the first matched will be loaded
// if true, all matched will be loaded and deep merged
const readCandidates = getPermsReadCandidates();
const res = yield loadConfig({
sources: readCandidates,
merge: false,
});
return {
perms: config,
path: sources.at(0),
};
if (!res.config)
return;
const relativePath = path.relative(process.cwd(), res.sources[0]);
return { path: relativePath, perms: res.config };
});

@@ -1182,24 +1213,57 @@ }

return __awaiter(this, void 0, void 0, function* () {
const { perms } = yield readLocalPermsFile();
if (!perms) {
const res = yield readLocalPermsFile();
if (!res) {
error(`We couldn't find your ${chalk.yellow('`instant.perms.ts`')} file. Make sure it's in the root directory.`);
}
return perms;
return res;
});
}
function getEnvSchemaPathWithLogging() {
const path = process.env.INSTANT_SCHEMA_FILE_PATH;
if (path) {
console.log(`Using INSTANT_SCHEMA_FILE_PATH=${chalk.green(process.env.INSTANT_SCHEMA_FILE_PATH)}`);
}
return path;
}
function getSchemaReadCandidates() {
const existing = getEnvSchemaPathWithLogging();
if (existing)
return [{ files: existing, transform: transformImports }];
return [
{
files: 'instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'src/instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'app/instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
];
}
function getSchemaPathToWrite(existingPath) {
if (existingPath)
return existingPath;
if (process.env.INSTANT_SCHEMA_FILE_PATH) {
return process.env.INSTANT_SCHEMA_FILE_PATH;
}
return 'instant.schema.ts';
}
function readLocalSchemaFile() {
return __awaiter(this, void 0, void 0, function* () {
return (yield loadConfig({
sources: [
// load from `instant.config.xx`
{
files: 'instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
],
// if false, the only the first matched will be loaded
// if true, all matched will be loaded and deep merged
const readCandidates = getSchemaReadCandidates();
const res = yield loadConfig({
sources: readCandidates,
merge: false,
})).config;
});
if (!res.config)
return;
const relativePath = path.relative(process.cwd(), res.sources[0]);
return { path: relativePath, schema: res.config };
});

@@ -1225,8 +1289,17 @@ }

return __awaiter(this, void 0, void 0, function* () {
const schema = yield readLocalSchemaFile();
if (!schema) {
var _a, _b;
const res = yield readLocalSchemaFile();
if (!res) {
error(`We couldn't find your ${chalk.yellow('`instant.schema.ts`')} file. Make sure it's in the root directory.`);
return;
}
return schema;
if (((_b = (_a = res.schema) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) !== 'InstantSchemaDef') {
error("We couldn't find your schema export.");
error('In your ' +
chalk.green('`instant.schema.ts`') +
' file, make sure you ' +
chalk.green('`export default schema`'));
return;
}
return res;
});

@@ -1233,0 +1306,0 @@ }

export default version;
declare const version: "v0.17.15";
declare const version: "v0.17.16-experimental.1";
//# sourceMappingURL=version.d.ts.map
// Autogenerated by publish_packages.clj
const version = 'v0.17.15';
const version = 'v0.17.16-experimental.1';
export default version;
//# sourceMappingURL=version.js.map
{
"name": "instant-cli",
"type": "module",
"version": "v0.17.15",
"version": "v0.17.16-experimental.1",
"description": "Instant's CLI",

@@ -26,8 +26,2 @@ "bin": {

},
"scripts": {
"test": "vitest",
"build": "rm -rf dist; tsc -p tsconfig.json",
"dev": "tsc -p tsconfig.json -w --skipLibCheck",
"publish-package": "npm publish --access public"
},
"devDependencies": {

@@ -41,3 +35,9 @@ "@babel/core": "^7.17.9",

"typescript": "^5.5.4"
},
"scripts": {
"test": "vitest",
"build": "rm -rf dist; tsc -p tsconfig.json",
"dev": "tsc -p tsconfig.json -w --skipLibCheck",
"publish-package": "pnpm publish --access public --no-git-checks"
}
}
}

@@ -5,3 +5,3 @@ // @ts-check

import { mkdir, writeFile, readFile } from 'fs/promises';
import { join } from 'path';
import path, { join } from 'path';
import { randomUUID } from 'crypto';

@@ -761,16 +761,17 @@ import jsonDiff from 'json-diff';

}
const prevSchema = await readLocalSchemaFile();
if (prevSchema) {
const ok = await promptOk(
const prev = await readLocalSchemaFile();
if (prev) {
const shouldContinue = await promptOk(
'This will overwrite your local instant.schema file, OK to proceed?',
);
if (!ok) return { ok: true };
if (!shouldContinue) return { ok: true };
}
const schemaPath = join(pkgDir, 'instant.schema.ts');
const schemaPath = join(pkgDir, getSchemaPathToWrite(prev?.path));
await writeTypescript(
schemaPath,
generateSchemaTypescriptFile(
prevSchema,
prev?.schema,
pullRes.data.schema,

@@ -797,12 +798,12 @@ instantModuleName,

if (!pullRes.ok) return;
if (await pathExists(join(pkgDir, 'instant.perms.ts'))) {
const ok = await promptOk(
const prev = await readLocalPermsFile();
if (prev) {
const shouldContinue = await promptOk(
'This will overwrite your local instant.perms file, OK to proceed?',
);
if (!ok) return;
if (!shouldContinue) return { ok: true };
}
const permsPath = join(pkgDir, 'instant.perms.ts');
const permsPath = join(pkgDir, getPermsPathToWrite(prev?.path));
await writeTypescript(

@@ -1017,5 +1018,5 @@ permsPath,

async function pushSchema(appId, opts) {
const schema = await readLocalSchemaFileWithErrorLogging();
if (!schema) return { ok: false };
const res = await readLocalSchemaFileWithErrorLogging();
if (!res) return { ok: false };
const { schema } = res;
console.log('Planning schema...');

@@ -1135,4 +1136,4 @@

async function pushPerms(appId) {
const perms = await readLocalPermsFileWithErrorLogging();
if (!perms) {
const res = await readLocalPermsFileWithErrorLogging();
if (!res) {
return;

@@ -1153,3 +1154,3 @@ }

prodPerms.data.perms || {},
perms || {},
res.perms || {},
);

@@ -1173,3 +1174,3 @@ if (!diffedStr.length) {

body: {
code: perms,
code: res.perms,
},

@@ -1343,26 +1344,56 @@ });

function getEnvPermsPathWithLogging() {
const path = process.env.INSTANT_PERMS_FILE_PATH;
if (path) {
console.log(
`Using INSTANT_PERMS_FILE_PATH=${chalk.green(process.env.INSTANT_PERMS_FILE_PATH)}`,
);
}
return path;
}
function getPermsReadCandidates() {
const existing = getEnvPermsPathWithLogging();
if (existing) return [{ files: existing, transform: transformImports }];
return [
{
files: 'instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'src/instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'app/instant.rules',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
];
}
function getPermsPathToWrite(existingPath) {
if (existingPath) return existingPath;
if (process.env.INSTANT_PERMS_FILE_PATH) {
return process.env.INSTANT_PERMS_FILE_PATH;
}
return 'instant.perms.ts';
}
async function readLocalPermsFile() {
const { config, sources } = await loadConfig({
sources: [
// load from `instant.perms.xx`
{
files: 'instant.perms',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
transform: transformImports,
},
],
// if false, the only the first matched will be loaded
// if true, all matched will be loaded and deep merged
const readCandidates = getPermsReadCandidates();
const res = await loadConfig({
sources: readCandidates,
merge: false,
});
return {
perms: config,
path: sources.at(0),
};
if (!res.config) return;
const relativePath = path.relative(process.cwd(), res.sources[0]);
return { path: relativePath, perms: res.config };
}
async function readLocalPermsFileWithErrorLogging() {
const { perms } = await readLocalPermsFile();
if (!perms) {
const res = await readLocalPermsFile();
if (!res) {
error(

@@ -1372,21 +1403,54 @@ `We couldn't find your ${chalk.yellow('`instant.perms.ts`')} file. Make sure it's in the root directory.`,

}
return perms;
return res;
}
function getEnvSchemaPathWithLogging() {
const path = process.env.INSTANT_SCHEMA_FILE_PATH;
if (path) {
console.log(
`Using INSTANT_SCHEMA_FILE_PATH=${chalk.green(process.env.INSTANT_SCHEMA_FILE_PATH)}`,
);
}
return path;
}
function getSchemaReadCandidates() {
const existing = getEnvSchemaPathWithLogging();
if (existing) return [{ files: existing, transform: transformImports }];
return [
{
files: 'instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'src/instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
{
files: 'app/instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
];
}
function getSchemaPathToWrite(existingPath) {
if (existingPath) return existingPath;
if (process.env.INSTANT_SCHEMA_FILE_PATH) {
return process.env.INSTANT_SCHEMA_FILE_PATH;
}
return 'instant.schema.ts';
}
async function readLocalSchemaFile() {
return (
await loadConfig({
sources: [
// load from `instant.config.xx`
{
files: 'instant.schema',
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'],
transform: transformImports,
},
],
// if false, the only the first matched will be loaded
// if true, all matched will be loaded and deep merged
merge: false,
})
).config;
const readCandidates = getSchemaReadCandidates();
const res = await loadConfig({
sources: readCandidates,
merge: false,
});
if (!res.config) return;
const relativePath = path.relative(process.cwd(), res.sources[0]);
return { path: relativePath, schema: res.config };
}

@@ -1412,5 +1476,5 @@

async function readLocalSchemaFileWithErrorLogging() {
const schema = await readLocalSchemaFile();
const res = await readLocalSchemaFile();
if (!schema) {
if (!res) {
error(

@@ -1422,3 +1486,14 @@ `We couldn't find your ${chalk.yellow('`instant.schema.ts`')} file. Make sure it's in the root directory.`,

return schema;
if (res.schema?.constructor?.name !== 'InstantSchemaDef') {
error("We couldn't find your schema export.");
error(
'In your ' +
chalk.green('`instant.schema.ts`') +
' file, make sure you ' +
chalk.green('`export default schema`'),
);
return;
}
return res;
}

@@ -1425,0 +1500,0 @@

// Autogenerated by publish_packages.clj
const version = 'v0.17.15';
const version = 'v0.17.16-experimental.1';
export default version;

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

Sorry, the diff of this file is not supported yet