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

@futura-dev/cosmodrome

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@futura-dev/cosmodrome - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0-alpha.1

2

dist/commands/init.js

@@ -28,2 +28,4 @@ "use strict";

fs.writeFileSync("./.cosmodrome.json", JSON.stringify({
preReleasePrefix: "",
releaseCommitPrefix: "",
git: {

@@ -30,0 +32,0 @@ authorEmail: "",

export type Flags = {
config: string;
};
export type SemanticVersionType = "major" | "minor" | "patch";
export type SemanticVersionType = "major" | "minor" | "patch" | "pre-release";
export type VersionActionType = "pre-release" | "promote" | "major" | "minor" | "patch";
/**

@@ -10,1 +11,28 @@ * COMMAND release

export declare const release: (flags: Flags) => Promise<void>;
/**
* How to:
*
* A. stable: a.b.c
* major (a+1).0.0
* minor a.(b+1).0
* patch a.b.(c+1)
* major-pr (a+1).0.0-x.1
* minor-pr a.(b+1).0-x.1
* patch-pr a.b.(c+1)-x.1
*
* B. pre-release: a.b.c-x.d
* pre-release a.b.c-x.(d+1)
* promote a.b.c
*
* example:
* 0.0.1 patch
* 0.0.2 patch
* 0.0.3 minor
* 0.1.0 patch
* 0.1.2 major-pr
* 1.0.0-x.1 pre-release
* 1.0.0-x.2 promote
* 1.0.0 minor-pr
* 1.1.0-x.1
*/
export declare const _computeNewVersion: (version: string, action: VersionActionType, preReleasePrefix: string, mustProducePreRelease: boolean) => `${number}.${number}.${number}` | `${number}.${number}.${number}-${string}.${number}`;

117

dist/commands/release.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.release = void 0;
exports._computeNewVersion = exports.release = void 0;
const tslib_1 = require("tslib");

@@ -57,12 +57,15 @@ const fs = tslib_1.__importStar(require("fs"));

}
// load and validate the root package.json
const p_json = package_json_1.root_package_json_schema.parse(JSON.parse(fs.readFileSync("./package.json", { encoding: "utf-8" })));
const _config = {
run: ".",
monorepo: false,
isCurrentAPreRelease: false,
detected_version: "",
new_version: ""
new_version: "",
packageJson: {},
mustBeAPreRelease: false,
};
// load and validate the root package.json
_config.packageJson = package_json_1.root_package_json_schema.parse(JSON.parse(fs.readFileSync("./package.json", { encoding: "utf-8" })));
// is a monorepo ?
const workspaces = p_json.workspaces;
const workspaces = _config.packageJson.workspaces;
if ((0, functions_1.isArray)(workspaces)) {

@@ -80,2 +83,3 @@ const workspace = await prompts.select({

_config.monorepo = true;
_config.packageJson = package_json_1.workspace_package_json_schema.parse(JSON.parse(fs.readFileSync(`${workspace}/package.json`, { encoding: "utf-8" })));
}

@@ -99,30 +103,29 @@ // STEP 0

};
// check if pre-release
_config.detected_version = _config.packageJson.version;
const isPreRelease = new RegExp(`\\d+\\.\\d+\\.\\d+-${config.preReleasePrefix}\\.\\d+`).test(_config.detected_version);
_config.isCurrentAPreRelease = isPreRelease;
// STEP 2
// choose the correct semantic version
const semantic = (await prompts.select({
const choices = isPreRelease
? [{ value: 'pre-release' }, { value: 'promote' }]
: [{ value: "major" }, { value: "minor" }, { value: "patch" }];
const action = (await prompts.select({
message: "choose a version type",
choices: [{ value: "major" }, { value: "minor" }, { value: "patch" }]
choices: choices,
}));
// MONOREPO
if (_config.monorepo) {
// read the target workspace package.json
const target_p_json = package_json_1.workspace_package_json_schema.parse(JSON.parse(fs.readFileSync(`${_config.run}/package.json`, { encoding: "utf-8" })));
// set repo config vars
const workspace_new_version = _computeNewVersion(target_p_json.version, semantic);
_config.detected_version = target_p_json.version;
_config.new_version = workspace_new_version;
repo_config.tagName = `${target_p_json.slug}@v${workspace_new_version}`;
repo_config.releaseName = `${target_p_json.name}@v${workspace_new_version}`;
repo_config.commitMessage = `release: ${target_p_json.name}@v${workspace_new_version}`;
if (!_config.isCurrentAPreRelease) {
_config.mustBeAPreRelease = await prompts.confirm({
message: "Is a pre-release ?",
default: false
});
}
// NO MONOREPO
else {
// set repo config vars
const root_new_version = _computeNewVersion(p_json.version, semantic);
_config.detected_version = p_json.version;
_config.new_version = root_new_version;
repo_config.tagName = `v${root_new_version}`;
repo_config.releaseName = `v${root_new_version}`;
repo_config.commitMessage = `release: v${root_new_version}`;
}
const newComputedVersion = (0, exports._computeNewVersion)(_config.detected_version, action, config.preReleasePrefix, action === 'pre-release' || _config.mustBeAPreRelease);
_config.new_version = newComputedVersion;
const slug = _config.packageJson.slug || null;
const projectNameOrSlug = slug || _config.packageJson.name;
const commitPrefix = config.releaseCommitPrefix;
repo_config.tagName = _config.monorepo ? `${projectNameOrSlug}@v${_config.new_version}` : `v${_config.new_version}`;
repo_config.releaseName = repo_config.tagName;
repo_config.commitMessage = `${commitPrefix}: ${repo_config.releaseName}`;
// STEP 3

@@ -152,3 +155,2 @@ // Update the version in package.json and package-lock.json

const git_provider_config = {
isPreRelease: false,
isDraft: false,

@@ -162,6 +164,2 @@ doesGenerateReleaseNotes: true,

if (git_provider === "GitHub") {
git_provider_config.isPreRelease = await prompts.confirm({
message: "Is a pre-release ?",
default: git_provider_config.isPreRelease
});
git_provider_config.isDraft = await prompts.confirm({

@@ -222,3 +220,3 @@ message: "Sign release as draft ?",

draft: git_provider_config.isDraft,
prerelease: git_provider_config.isPreRelease,
prerelease: _config.mustBeAPreRelease,
generate_release_notes: git_provider_config.doesGenerateReleaseNotes

@@ -246,14 +244,51 @@ }, {

exports.release = release;
const _computeNewVersion = (version, result) => {
if (version.split(".").length !== 3)
/**
* How to:
*
* A. stable: a.b.c
* major (a+1).0.0
* minor a.(b+1).0
* patch a.b.(c+1)
* major-pr (a+1).0.0-x.1
* minor-pr a.(b+1).0-x.1
* patch-pr a.b.(c+1)-x.1
*
* B. pre-release: a.b.c-x.d
* pre-release a.b.c-x.(d+1)
* promote a.b.c
*
* example:
* 0.0.1 patch
* 0.0.2 patch
* 0.0.3 minor
* 0.1.0 patch
* 0.1.2 major-pr
* 1.0.0-x.1 pre-release
* 1.0.0-x.2 promote
* 1.0.0 minor-pr
* 1.1.0-x.1
*/
const _computeNewVersion = (version, action, preReleasePrefix, mustProducePreRelease) => {
if (version.split(".").length < 3)
throw new Error("version is bad formatted");
const semanticVersion = version.split(".").map(string => Number(string));
switch (result) {
const stableSemanticVersionPieces = version
.split('-')[0]
.split(".")
.slice(0, 3)
.map(i => Number(i));
const preReleasePiece = version.split('-').pop() || null;
const [_, preReleaseNumber] = preReleasePiece?.split('.') || [null, null];
switch (action) {
case "major":
return `${semanticVersion[0] + 1}.0.0`;
return mustProducePreRelease ? `${stableSemanticVersionPieces[0] + 1}.0.0-${preReleasePrefix}.1` : `${stableSemanticVersionPieces[0] + 1}.0.0`;
case "minor":
return `${semanticVersion[0]}.${semanticVersion[1] + 1}.0`;
return mustProducePreRelease ? `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1] + 1}.0-${preReleasePrefix}.1` : `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1] + 1}.0`;
case "patch":
return `${semanticVersion[0]}.${semanticVersion[1]}.${semanticVersion[2] + 1}`;
return mustProducePreRelease ? `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1]}.${stableSemanticVersionPieces[2] + 1}-${preReleasePrefix}.1` : `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1]}.${stableSemanticVersionPieces[2] + 1}`;
case 'pre-release':
return `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1]}.${stableSemanticVersionPieces[2]}-${preReleasePrefix}.${Number(preReleaseNumber) + 1}`;
case 'promote':
return `${stableSemanticVersionPieces[0]}.${stableSemanticVersionPieces[1]}.${stableSemanticVersionPieces[2]}`;
}
};
exports._computeNewVersion = _computeNewVersion;
{
"name": "@futura-dev/cosmodrome",
"version": "1.4.1",
"version": "1.5.0-alpha.1",
"private": false,

@@ -29,3 +29,4 @@ "repository": {

"release": "node ./dist/cli.js release",
"lint:beautify": "npm run lint:fix && prettier ./src --write"
"lint:beautify": "npm run lint:fix && prettier ./src --write",
"test": "jest"
},

@@ -45,7 +46,11 @@ "dependencies": {

"@futura-dev/eslint-config-typescript": "^0.1.4",
"@jest/globals": "^29.7.0",
"@types/commander": "^2.12.2",
"@types/jest": "^29.5.14",
"@types/mute-stream": "^0.0.1",
"@types/node": "^20.11.17",
"fp-ts": "^2.15.0",
"jest": "^29.7.0",
"npm-check-updates": "^16.14.15",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",

@@ -55,3 +60,3 @@ "typescript": "^5.3.3"

"engines": {
"node": ">=18"
"node": ">=22.6.0"
},

@@ -58,0 +63,0 @@ "bugs": "https://github.com/futura-dev/cosmodrome/issues",

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

/// <reference types="node" />
/**

@@ -3,0 +2,0 @@ * controlledSpawn

import { z } from "zod";
export declare const cosmodrome_config_schema: z.ZodObject<{
preReleasePrefix: z.ZodString;
releaseCommitPrefix: z.ZodString;
git: z.ZodObject<{

@@ -27,2 +29,4 @@ authorEmail: z.ZodString;

}, "strip", z.ZodTypeAny, {
preReleasePrefix: string;
releaseCommitPrefix: string;
git: {

@@ -38,2 +42,4 @@ authorEmail: string;

}, {
preReleasePrefix: string;
releaseCommitPrefix: string;
git: {

@@ -40,0 +46,0 @@ authorEmail: string;

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

exports.cosmodrome_config_schema = zod_1.z.object({
preReleasePrefix: zod_1.z.string(),
releaseCommitPrefix: zod_1.z.string(),
git: zod_1.z.object({

@@ -8,0 +10,0 @@ authorEmail: zod_1.z.string(),

{
"name": "@futura-dev/cosmodrome",
"version": "1.4.1",
"version": "1.5.0-alpha.1",
"private": false,

@@ -29,3 +29,4 @@ "repository": {

"release": "node ./dist/cli.js release",
"lint:beautify": "npm run lint:fix && prettier ./src --write"
"lint:beautify": "npm run lint:fix && prettier ./src --write",
"test": "jest"
},

@@ -45,7 +46,11 @@ "dependencies": {

"@futura-dev/eslint-config-typescript": "^0.1.4",
"@jest/globals": "^29.7.0",
"@types/commander": "^2.12.2",
"@types/jest": "^29.5.14",
"@types/mute-stream": "^0.0.1",
"@types/node": "^20.11.17",
"fp-ts": "^2.15.0",
"jest": "^29.7.0",
"npm-check-updates": "^16.14.15",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",

@@ -55,3 +60,3 @@ "typescript": "^5.3.3"

"engines": {
"node": ">=18"
"node": ">=22.6.0"
},

@@ -58,0 +63,0 @@ "bugs": "https://github.com/futura-dev/cosmodrome/issues",

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