Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
Expand Down Expand Up @@ -30,4 +27,4 @@ jobs:
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.MOCKTAIL_CLI_CI_TOKEN }}
30 changes: 15 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: mocktail-cli
name: Publish Mocktail CLI

on:
push:
branches:
- main # or your default branch
- main

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
# 1️⃣ Checkout code
- uses: actions/checkout@v4

# 2️⃣ Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/

# 3️⃣ Install dependencies
- name: Install dependencies
run: npm install
run: npm ci

# 4️⃣ Run tests
- name: Run tests
run: npm test

- name: Set up npm auth
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.MOCKTAIL_CLI_CI_TOKEN }}


- name: Publish to npm
run: npm publish --access public
# 5️⃣ Publish with auto-bump
- name: Publish packages
run: node publish.js
env:
NODE_AUTH_TOKEN: ${{ secrets.MOCKTAIL_CLI_CI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.env
.DS_Store
mock-output/
*.log
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Business Source License 1.1

Copyright (c) 2025 Mock-Verse
Copyright (c) 2025 Mockilo

1. License Grant:
You may use, copy, modify, and distribute this software for personal, educational, or internal business use only.

2. Restrictions:
You may NOT provide the software as a hosted service, commercial SaaS, or for commercial distribution without obtaining a commercial license from Mock-Verse.
You may NOT provide the software as a hosted service, commercial SaaS, or for commercial distribution without obtaining a commercial license from Mockilo.

3. Change Date:

Expand All @@ -15,4 +15,4 @@ Copyright (c) 2025 Mock-Verse
4. Warranty:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.

For commercial licensing inquiries, contact: contact@mock-verse.com
For commercial licensing inquiries, contact: contact@mockilo.com
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Takeaway:

* v1.0: CLI complete with flags for depth, output formats, custom config.
* v1.1: ✅ Schema auto-detection, advanced relation presets (blog, ecommerce, social).
* v1.2+: Integration with Mock-Verse for API mocking, seeding, and team workflows.
* v1.2+: Integration with Mockilo for API mocking, seeding, and team workflows.

---

Expand Down
2 changes: 1 addition & 1 deletion bin/mocktail-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ${chalk.magenta('Commands:')}

${chalk.cyan('For detailed documentation, run:')}
${chalk.green('mocktail-cli docs')}
${chalk.cyan('Or visit')} ${chalk.underline.blue('https://github.com/mock-verse/mocktail-cli')}
${chalk.cyan('Or visit')} ${chalk.underline.blue('https://github.com/mockilo/mocktail-cli')}
`;
};

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mocktail-cli",
"version": "1.1.1-beta.4",
"version": "1.1.1-beta.7",
"description": "**Craft your data cocktail — realistic mock data, shaken not stirred.**",
"main": "bin/mocktail-cli.js",
"type": "commonjs",
Expand All @@ -18,12 +18,7 @@
"CLI",
"mocktail",
"mocktail-cli",
"mocktail-cli-beta",
"mocktail-cli-beta-3",
"mocktail-cli-beta-3-beta",
"mocktail-cli-beta-3-beta-3",
"mocktail-cli-beta-3-beta-3-beta",
"CLI",
"mockilo",
"ORM",
"Prisma",
"prisma2",
Expand All @@ -35,8 +30,7 @@
"Node.js",
"Node",
"Nodejs",
"NodeJS",
"Nodejs"
"NodeJS"
],
"author": "kilopal",
"license": "BSL-1.1",
Expand All @@ -48,6 +42,9 @@
"nanoid": "^5.1.5",
"ora": "^8.2.0"
},
"publishConfig": {
"access": "public"
},
"bin": {
"mocktail-cli": "bin/mocktail-cli.js"
},
Expand All @@ -62,12 +59,12 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/mock-verse/mocktail-cli.git"
"url": "git+https://github.com/mockilo/mocktail-cli.git"
},
"bugs": {
"url": "https://github.com/mock-verse/mocktail-cli/issues"
"url": "https://github.com/mockilo/mocktail-cli/issues"
},
"homepage": "https://github.com/mock-verse/mocktail-cli#readme",
"homepage": "https://github.com/mockilo/mocktail-cli#readme",
"directories": {
"test": "tests"
}
Expand Down
71 changes: 71 additions & 0 deletions package.scoped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "@mockilo/mocktail-cli",
"version": "1.1.1-beta.7",
"description": "**Craft your data cocktail — realistic mock data, shaken not stirred.**",
"main": "bin/mocktail-cli.js",
"type": "commonjs",
"scripts": {
"test": "jest",
"start": "node ./bin/mocktail-cli.js",
"lint": "echo \"No lint configured\""
},
"keywords": [
"mock",
"api",
"schema",
"faker",
"prisma",
"CLI",
"mocktail",
"mocktail-cli",
"mockilo",
"ORM",
"Prisma",
"prisma2",
"database",
"JavaScript",
"JS",
"TypeScript",
"TS",
"Node.js",
"Node",
"Nodejs",
"NodeJS"
],
"author": "kilopal",
"license": "BSL-1.1",
"dependencies": {
"@faker-js/faker": "^9.9.0",
"@prisma/client": "^6.13.0",
"chalk": "^4.1.2",
"commander": "^14.0.0",
"nanoid": "^5.1.5",
"ora": "^8.2.0"
},
"publishConfig": {
"access": "public"
},
"bin": {
"mocktail-cli": "bin/mocktail-cli.js"
},
"engines": {
"node": ">=18.18.0"
},
"devDependencies": {
"@eslint/js": "^9.33.0",
"eslint": "^9.33.0",
"globals": "^16.3.0",
"jest": "^30.0.5"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mockilo/mocktail-cli.git"
},
"bugs": {
"url": "https://github.com/mockilo/mocktail-cli/issues"
},
"homepage": "https://github.com/mockilo/mocktail-cli#readme",
"directories": {
"test": "tests"
}
}
95 changes: 95 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env node
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");

const repoRoot = __dirname;
const standalonePkg = path.join(repoRoot, "package.json");
const scopedPkg = path.join(repoRoot, "package.scoped.json");

// --- NEW: branch guard ---
function getCurrentBranch() {
try {
return execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
} catch {
return null;
}
}

const branch = getCurrentBranch();
if (branch && branch !== "main") {
console.log(`⚠️ Skipping publish: current branch is '${branch}', not 'main'.`);
process.exit(0);
}
// -------------------------

// Parse version into [major, minor, patch, pre, preNum]
function parseVersion(v) {
const [main, pre] = v.split("-");
const [major, minor, patch] = main.split(".").map((n) => parseInt(n));
let preNum = null;
if (pre) {
const match = pre.match(/([a-z]+)\.?(\d+)?/i);
if (match) preNum = parseInt(match[2] || 0);
}
return { major, minor, patch, pre, preNum };
}

function bumpBeta(version) {
const { major, minor, patch, pre, preNum } = parseVersion(version);
if (pre && pre.startsWith("beta")) {
return `${major}.${minor}.${patch}-beta.${preNum + 1}`;
} else {
return `${major}.${minor}.${patch}-beta.1`;
}
}

function getPublishedVersion(pkgName) {
try {
return execSync(`npm view ${pkgName} version`, { stdio: ["pipe", "pipe", "ignore"] })
.toString()
.trim();
} catch {
return null;
}
}

function updateVersion(pkgPath, newVersion) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
pkg.version = newVersion;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
console.log(`🔼 Updated ${pkg.name} to version ${newVersion}`);
return newVersion;
}

function publishPackage(pkgPath) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
const publishedVersion = getPublishedVersion(pkg.name);
let newVersion = pkg.version;

if (publishedVersion && publishedVersion === pkg.version) {
newVersion = bumpBeta(publishedVersion);
updateVersion(pkgPath, newVersion);
}

console.log(`📦 Publishing ${pkg.name}@${newVersion}...`);
execSync("npm publish --access public", { cwd: repoRoot, stdio: "inherit" });

return newVersion;
}

function publishBoth() {
publishPackage(standalonePkg);

if (fs.existsSync(scopedPkg)) {
const backupPkg = path.join(repoRoot, "package.json.bak");
fs.renameSync(standalonePkg, backupPkg);
fs.copyFileSync(scopedPkg, standalonePkg);
publishPackage(standalonePkg);
fs.renameSync(backupPkg, standalonePkg);
}

console.log("✅ All packages published successfully!");
}

publishBoth();
23 changes: 23 additions & 0 deletions schemas/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "User",
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"email": { "type": "string", "format": "email" },
"posts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"title": { "type": "string" },
"content": { "type": "string" }
},
"required": ["id", "title"]
}
}
},
"required": ["id", "name", "email"]
}