@igniter-js/cli 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js +70 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11489,16 +11489,7 @@ function extractRouterSchema(router) {
|
|
|
11489
11489
|
};
|
|
11490
11490
|
}
|
|
11491
11491
|
const schema = {
|
|
11492
|
-
|
|
11493
|
-
baseURL: router.config?.baseURL || "",
|
|
11494
|
-
basePATH: router.config?.basePATH || ""
|
|
11495
|
-
},
|
|
11496
|
-
controllers: controllersSchema,
|
|
11497
|
-
processor: {},
|
|
11498
|
-
handler: {},
|
|
11499
|
-
$context: {},
|
|
11500
|
-
$plugins: {},
|
|
11501
|
-
$caller: {}
|
|
11492
|
+
controllers: controllersSchema
|
|
11502
11493
|
};
|
|
11503
11494
|
return {
|
|
11504
11495
|
schema,
|
|
@@ -11604,28 +11595,40 @@ export type AppRouterSchemaType = typeof AppRouterSchema
|
|
|
11604
11595
|
return filePath;
|
|
11605
11596
|
}
|
|
11606
11597
|
async function generateClientFile(schema, outputDir, config) {
|
|
11607
|
-
const
|
|
11598
|
+
const filePath = path7.join(outputDir, "igniter.client.ts");
|
|
11599
|
+
if (fs6.existsSync(filePath)) {
|
|
11600
|
+
const logger6 = createChildLogger({ component: "generator" });
|
|
11601
|
+
logger6.info("Skipping client file generation, already exists", { path: filePath });
|
|
11602
|
+
return filePath;
|
|
11603
|
+
}
|
|
11604
|
+
const content = `* eslint-disable */
|
|
11605
|
+
/* prettier-ignore */
|
|
11606
|
+
|
|
11607
|
+
import { createIgniterClient, useIgniterQueryClient } from '@igniter-js/core/client'
|
|
11608
11608
|
import type { AppRouterType } from './igniter.router'
|
|
11609
11609
|
|
|
11610
11610
|
/**
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11611
|
+
* Type-safe API client generated from your Igniter router
|
|
11612
|
+
*
|
|
11613
|
+
* Usage in Server Components:
|
|
11614
|
+
* const users = await api.users.list.query()
|
|
11615
|
+
*
|
|
11616
|
+
* Usage in Client Components:
|
|
11617
|
+
* const { data } = api.users.list.useQuery()
|
|
11618
|
+
*
|
|
11619
|
+
* Note: Adjust environment variable prefixes (e.g., NEXT_PUBLIC_, BUN_PUBLIC_, DENO_PUBLIC_, REACT_APP_)
|
|
11620
|
+
* according to your project's framework/runtime (Next.js, Bun, Deno, React/Vite, etc.).
|
|
11621
|
+
*/
|
|
11619
11622
|
export const api = createIgniterClient<AppRouterType>({
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11623
|
+
baseURL: process.env.NEXT_PUBLIC_IGNITER_API_URL, // Adapt for your needs
|
|
11624
|
+
basePath: process.env.NEXT_PUBLIC_IGNITER_API_BASE_PATH,
|
|
11625
|
+
router: () => {
|
|
11626
|
+
if (typeof window === 'undefined') {
|
|
11627
|
+
return require('./igniter.router').AppRouter
|
|
11628
|
+
}
|
|
11626
11629
|
|
|
11627
|
-
|
|
11628
|
-
|
|
11630
|
+
return require('./igniter.schema').AppRouterSchema
|
|
11631
|
+
},
|
|
11629
11632
|
})
|
|
11630
11633
|
|
|
11631
11634
|
/**
|
|
@@ -11647,7 +11650,6 @@ export type ApiClient = typeof api
|
|
|
11647
11650
|
*/
|
|
11648
11651
|
export const useQueryClient = useIgniterQueryClient<AppRouterType>;
|
|
11649
11652
|
`;
|
|
11650
|
-
const filePath = path7.join(outputDir, "igniter.client.ts");
|
|
11651
11653
|
await writeFileWithHeader(filePath, content, config);
|
|
11652
11654
|
return filePath;
|
|
11653
11655
|
}
|
|
@@ -11658,7 +11660,8 @@ async function writeFileWithHeader(filePath, content, config) {
|
|
|
11658
11660
|
}
|
|
11659
11661
|
function generateFileHeader(config) {
|
|
11660
11662
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
11661
|
-
return `/* eslint-disable
|
|
11663
|
+
return `/* eslint-disable */
|
|
11664
|
+
/* prettier-ignore */
|
|
11662
11665
|
|
|
11663
11666
|
/**
|
|
11664
11667
|
* Generated by @igniter-js/cli
|
|
@@ -12491,11 +12494,12 @@ function showWelcome() {
|
|
|
12491
12494
|
console.log(chalk2.dim("This process will configure your project with everything you need."));
|
|
12492
12495
|
console.log();
|
|
12493
12496
|
}
|
|
12494
|
-
async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
12497
|
+
async function runSetupPrompts(targetDir, isExistingProject = false, cliOptions = {}) {
|
|
12495
12498
|
showWelcome();
|
|
12496
12499
|
const detectedFramework = detectFramework();
|
|
12497
12500
|
const detectedPackageManager = detectPackageManager();
|
|
12498
12501
|
const projectName = targetDir ? path3.basename(path3.resolve(targetDir)) : "my-igniter-app";
|
|
12502
|
+
const cliFeatures = cliOptions.features ? cliOptions.features.split(",").map((f) => f.trim()) : [];
|
|
12499
12503
|
try {
|
|
12500
12504
|
const answers = await prompts([
|
|
12501
12505
|
{
|
|
@@ -12513,8 +12517,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12513
12517
|
format: (value) => value.trim().toLowerCase().replace(/\s+/g, "-")
|
|
12514
12518
|
},
|
|
12515
12519
|
{
|
|
12516
|
-
type:
|
|
12517
|
-
// Show if not existing project OR if existing but no framework detected
|
|
12520
|
+
type: cliOptions.template || isExistingProject && detectedFramework ? null : "select",
|
|
12518
12521
|
name: "framework",
|
|
12519
12522
|
message: "\u2022 Which starter would you like to use?",
|
|
12520
12523
|
choices: [
|
|
@@ -12545,7 +12548,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12545
12548
|
]
|
|
12546
12549
|
},
|
|
12547
12550
|
{
|
|
12548
|
-
type: "multiselect",
|
|
12551
|
+
type: cliOptions.features ? null : "multiselect",
|
|
12549
12552
|
name: "features",
|
|
12550
12553
|
message: chalk2.bold("\u2022 Which Igniter.js features would you like to enable?"),
|
|
12551
12554
|
choices: [
|
|
@@ -12582,7 +12585,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12582
12585
|
instructions: chalk2.dim("Use \u2191\u2193 to navigate, space to select, enter to confirm")
|
|
12583
12586
|
},
|
|
12584
12587
|
{
|
|
12585
|
-
type: "select",
|
|
12588
|
+
type: cliOptions.database ? null : "select",
|
|
12586
12589
|
name: "database",
|
|
12587
12590
|
message: chalk2.bold("\u2022 Choose your database (optional):"),
|
|
12588
12591
|
choices: [
|
|
@@ -12606,14 +12609,18 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12606
12609
|
initial: 0
|
|
12607
12610
|
},
|
|
12608
12611
|
{
|
|
12609
|
-
type: (prev) =>
|
|
12612
|
+
type: (prev) => {
|
|
12613
|
+
if (cliOptions.docker === false) return null;
|
|
12614
|
+
const dbValue = cliOptions.database || prev;
|
|
12615
|
+
return dbValue !== "none" ? "confirm" : null;
|
|
12616
|
+
},
|
|
12610
12617
|
name: "dockerCompose",
|
|
12611
12618
|
message: chalk2.bold("\u2022 Setup Docker Compose for development?"),
|
|
12612
12619
|
hint: chalk2.dim("Includes Redis and your selected database"),
|
|
12613
|
-
initial:
|
|
12620
|
+
initial: cliOptions.docker !== false
|
|
12614
12621
|
},
|
|
12615
12622
|
{
|
|
12616
|
-
type: "select",
|
|
12623
|
+
type: cliOptions.packageManager ? null : "select",
|
|
12617
12624
|
name: "packageManager",
|
|
12618
12625
|
message: isExistingProject ? `We detected ${chalk2.cyan(detectedPackageManager)}. Please confirm or select another.` : chalk2.bold("\u2022 Which package manager?"),
|
|
12619
12626
|
choices: [
|
|
@@ -12634,19 +12641,19 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12634
12641
|
value: "bun"
|
|
12635
12642
|
}
|
|
12636
12643
|
],
|
|
12637
|
-
initial: getPackageManagerChoiceIndex(detectedPackageManager)
|
|
12644
|
+
initial: getPackageManagerChoiceIndex(cliOptions.packageManager || detectedPackageManager)
|
|
12638
12645
|
},
|
|
12639
12646
|
{
|
|
12640
|
-
type: isExistingProject ? null : "confirm",
|
|
12647
|
+
type: isExistingProject || cliOptions.git === false ? null : "confirm",
|
|
12641
12648
|
name: "initGit",
|
|
12642
12649
|
message: chalk2.bold("\u2022 Initialize Git repository?"),
|
|
12643
|
-
initial:
|
|
12650
|
+
initial: cliOptions.git !== false
|
|
12644
12651
|
},
|
|
12645
12652
|
{
|
|
12646
|
-
type: "confirm",
|
|
12653
|
+
type: cliOptions.install === false ? null : "confirm",
|
|
12647
12654
|
name: "installDependencies",
|
|
12648
12655
|
message: chalk2.bold("\u2022 Install dependencies automatically?"),
|
|
12649
|
-
initial:
|
|
12656
|
+
initial: cliOptions.install !== false
|
|
12650
12657
|
}
|
|
12651
12658
|
], {
|
|
12652
12659
|
onCancel: () => {
|
|
@@ -12654,22 +12661,24 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12654
12661
|
process.exit(0);
|
|
12655
12662
|
}
|
|
12656
12663
|
});
|
|
12664
|
+
const selectedFeatures = cliOptions.features ? cliFeatures : answers.features || [];
|
|
12665
|
+
const hasExplicitFeatures = cliOptions.features || answers.features && answers.features.length > 0;
|
|
12657
12666
|
const featuresObj = {
|
|
12658
|
-
store:
|
|
12659
|
-
jobs:
|
|
12660
|
-
mcp:
|
|
12661
|
-
logging:
|
|
12662
|
-
telemetry:
|
|
12667
|
+
store: selectedFeatures.includes("store"),
|
|
12668
|
+
jobs: selectedFeatures.includes("jobs"),
|
|
12669
|
+
mcp: selectedFeatures.includes("mcp"),
|
|
12670
|
+
logging: selectedFeatures.includes("logging") || !hasExplicitFeatures,
|
|
12671
|
+
telemetry: selectedFeatures.includes("telemetry") || !hasExplicitFeatures
|
|
12663
12672
|
};
|
|
12664
12673
|
const config = {
|
|
12665
12674
|
projectName: answers.projectName || projectName,
|
|
12666
|
-
framework: answers.framework,
|
|
12675
|
+
framework: cliOptions.template || answers.framework,
|
|
12667
12676
|
features: featuresObj,
|
|
12668
|
-
database: { provider: answers.database },
|
|
12669
|
-
packageManager: answers.packageManager,
|
|
12670
|
-
initGit: answers.initGit
|
|
12671
|
-
installDependencies: answers.installDependencies,
|
|
12672
|
-
dockerCompose: answers.dockerCompose || false
|
|
12677
|
+
database: { provider: cliOptions.database || answers.database || "none" },
|
|
12678
|
+
packageManager: cliOptions.packageManager || answers.packageManager || detectedPackageManager,
|
|
12679
|
+
initGit: cliOptions.git !== false && (answers.initGit !== void 0 ? answers.initGit : !isExistingProject),
|
|
12680
|
+
installDependencies: cliOptions.install !== false && answers.installDependencies !== false,
|
|
12681
|
+
dockerCompose: cliOptions.docker !== false && (answers.dockerCompose || false)
|
|
12673
12682
|
};
|
|
12674
12683
|
showConfigSummary(config);
|
|
12675
12684
|
return config;
|
|
@@ -12730,7 +12739,7 @@ var IGNITER_FEATURES = {
|
|
|
12730
12739
|
name: "Redis Store",
|
|
12731
12740
|
description: "Caching, sessions, and pub/sub messaging",
|
|
12732
12741
|
dependencies: [
|
|
12733
|
-
{ name: "@igniter-js/adapter-redis", version: "
|
|
12742
|
+
{ name: "@igniter-js/adapter-redis", version: "latest" },
|
|
12734
12743
|
{ name: "ioredis", version: "^5.6.1" }
|
|
12735
12744
|
],
|
|
12736
12745
|
devDependencies: [
|
|
@@ -12758,8 +12767,8 @@ var IGNITER_FEATURES = {
|
|
|
12758
12767
|
name: "BullMQ Jobs",
|
|
12759
12768
|
description: "Background task processing and job queues",
|
|
12760
12769
|
dependencies: [
|
|
12761
|
-
{ name: "@igniter-js/adapter-redis", version: "
|
|
12762
|
-
{ name: "@igniter-js/adapter-bullmq", version: "
|
|
12770
|
+
{ name: "@igniter-js/adapter-redis", version: "latest" },
|
|
12771
|
+
{ name: "@igniter-js/adapter-bullmq", version: "latest" },
|
|
12763
12772
|
{ name: "bullmq", version: "^4.0.0" },
|
|
12764
12773
|
{ name: "ioredis", version: "^5.6.1" }
|
|
12765
12774
|
],
|
|
@@ -12787,7 +12796,7 @@ var IGNITER_FEATURES = {
|
|
|
12787
12796
|
name: "MCP Server",
|
|
12788
12797
|
description: "Easy expose your API as a MCP server for AI assistants like Cursor, Claude, etc.",
|
|
12789
12798
|
dependencies: [
|
|
12790
|
-
{ name: "@igniter-js/adapter-mcp", version: "
|
|
12799
|
+
{ name: "@igniter-js/adapter-mcp", version: "latest" },
|
|
12791
12800
|
{ name: "@vercel/mcp-adapter", version: "^0.2.0" },
|
|
12792
12801
|
{ name: "@modelcontextprotocol/sdk", version: "^1.10.2" },
|
|
12793
12802
|
{ name: "ioredis", version: "^5.6.1" }
|
|
@@ -12819,7 +12828,7 @@ var IGNITER_FEATURES = {
|
|
|
12819
12828
|
name: "Enhanced Logging",
|
|
12820
12829
|
description: "Advanced console logging with structured output",
|
|
12821
12830
|
dependencies: [
|
|
12822
|
-
{ name: "@igniter-js/core", version: "
|
|
12831
|
+
{ name: "@igniter-js/core", version: "latest" }
|
|
12823
12832
|
],
|
|
12824
12833
|
envVars: [
|
|
12825
12834
|
{ key: "IGNITER_LOG_LEVEL", value: "info", description: "Logging level (debug, info, warn, error)" }
|
|
@@ -12830,7 +12839,7 @@ var IGNITER_FEATURES = {
|
|
|
12830
12839
|
name: "Telemetry",
|
|
12831
12840
|
description: "Telemetry for tracking requests and errors",
|
|
12832
12841
|
dependencies: [
|
|
12833
|
-
{ name: "@igniter-js/core", version: "
|
|
12842
|
+
{ name: "@igniter-js/core", version: "latest" }
|
|
12834
12843
|
],
|
|
12835
12844
|
envVars: [
|
|
12836
12845
|
{ key: "IGNITER_TELEMETRY_ENABLE_TRACING", value: "true", description: "Enable telemetry tracing" },
|
|
@@ -14447,7 +14456,7 @@ async function handleGenerateProcedure(name, feature) {
|
|
|
14447
14456
|
// src/index.ts
|
|
14448
14457
|
var program = new Command();
|
|
14449
14458
|
program.name("igniter").description("CLI for Igniter.js type-safe client generation").version("1.0.0");
|
|
14450
|
-
program.command("init").description("Create a new Igniter.js project with interactive setup").argument("[project-name]", "Name of the project directory").option("--force", "Skip confirmation prompts and overwrite existing files").option("--pm, --package-manager <manager>", "Package manager to use (npm, yarn, pnpm, bun)").option("--template <template>", "Use a specific template (
|
|
14459
|
+
program.command("init").description("Create a new Igniter.js project with interactive setup").argument("[project-name]", "Name of the project directory").option("--force", "Skip confirmation prompts and overwrite existing files").option("--pm, --package-manager <manager>", "Package manager to use (npm, yarn, pnpm, bun)").option("--template <template>", "Use a specific template (e.g., starter-nextjs, starter-express-rest-api)").option("-f, --framework <framework>", "Target framework (nextjs, vite, etc.)").option("--features <features>", "Comma-separated list of features (store,jobs,mcp,logging,telemetry)").option("--database <database>", "Database provider (none, postgresql, mysql, sqlite)").option("--orm <orm>", "ORM provider (prisma, drizzle)").option("--no-git", "Skip git repository initialization").option("--no-install", "Skip automatic dependency installation").option("--no-docker", "Skip Docker Compose setup").action(async (projectName, options) => {
|
|
14451
14460
|
const initLogger = createChildLogger({ component: "init-command" });
|
|
14452
14461
|
try {
|
|
14453
14462
|
if (!projectName) {
|
|
@@ -14484,7 +14493,7 @@ program.command("init").description("Create a new Igniter.js project with intera
|
|
|
14484
14493
|
}
|
|
14485
14494
|
}
|
|
14486
14495
|
}
|
|
14487
|
-
const config = await runSetupPrompts(targetDir, isExistingProject);
|
|
14496
|
+
const config = await runSetupPrompts(targetDir, isExistingProject, options);
|
|
14488
14497
|
const validation = validateConfig(config);
|
|
14489
14498
|
if (!validation.isValid) {
|
|
14490
14499
|
console.error(`\u2717 ${validation.message}`);
|