@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/README.md
CHANGED
|
@@ -31,7 +31,7 @@ The `init` command scaffolds a new, production-ready Igniter.js project from scr
|
|
|
31
31
|
npx @igniter-js/cli init my-api
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
For more details, see the **[igniter init documentation](https://
|
|
34
|
+
For more details, see the **[igniter init documentation](https://igniterjs.com/docs/cli-and-tooling/igniter-init)**.
|
|
35
35
|
|
|
36
36
|
### `igniter dev`
|
|
37
37
|
|
|
@@ -46,7 +46,7 @@ igniter dev --interactive
|
|
|
46
46
|
igniter dev --interactive --framework nextjs
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
For more details, see the **[igniter dev documentation](https://
|
|
49
|
+
For more details, see the **[igniter dev documentation](https://igniterjs.com/docs/cli-and-tooling/igniter-dev)**.
|
|
50
50
|
|
|
51
51
|
## Contributing
|
|
52
52
|
|
package/dist/index.js
CHANGED
|
@@ -11482,16 +11482,7 @@ function extractRouterSchema(router) {
|
|
|
11482
11482
|
};
|
|
11483
11483
|
}
|
|
11484
11484
|
const schema = {
|
|
11485
|
-
|
|
11486
|
-
baseURL: router.config?.baseURL || "",
|
|
11487
|
-
basePATH: router.config?.basePATH || ""
|
|
11488
|
-
},
|
|
11489
|
-
controllers: controllersSchema,
|
|
11490
|
-
processor: {},
|
|
11491
|
-
handler: {},
|
|
11492
|
-
$context: {},
|
|
11493
|
-
$plugins: {},
|
|
11494
|
-
$caller: {}
|
|
11485
|
+
controllers: controllersSchema
|
|
11495
11486
|
};
|
|
11496
11487
|
return {
|
|
11497
11488
|
schema,
|
|
@@ -11597,28 +11588,40 @@ export type AppRouterSchemaType = typeof AppRouterSchema
|
|
|
11597
11588
|
return filePath;
|
|
11598
11589
|
}
|
|
11599
11590
|
async function generateClientFile(schema, outputDir, config) {
|
|
11600
|
-
const
|
|
11591
|
+
const filePath = path7.join(outputDir, "igniter.client.ts");
|
|
11592
|
+
if (fs6.existsSync(filePath)) {
|
|
11593
|
+
const logger6 = createChildLogger({ component: "generator" });
|
|
11594
|
+
logger6.info("Skipping client file generation, already exists", { path: filePath });
|
|
11595
|
+
return filePath;
|
|
11596
|
+
}
|
|
11597
|
+
const content = `* eslint-disable */
|
|
11598
|
+
/* prettier-ignore */
|
|
11599
|
+
|
|
11600
|
+
import { createIgniterClient, useIgniterQueryClient } from '@igniter-js/core/client'
|
|
11601
11601
|
import type { AppRouterType } from './igniter.router'
|
|
11602
11602
|
|
|
11603
11603
|
/**
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11604
|
+
* Type-safe API client generated from your Igniter router
|
|
11605
|
+
*
|
|
11606
|
+
* Usage in Server Components:
|
|
11607
|
+
* const users = await api.users.list.query()
|
|
11608
|
+
*
|
|
11609
|
+
* Usage in Client Components:
|
|
11610
|
+
* const { data } = api.users.list.useQuery()
|
|
11611
|
+
*
|
|
11612
|
+
* Note: Adjust environment variable prefixes (e.g., NEXT_PUBLIC_, BUN_PUBLIC_, DENO_PUBLIC_, REACT_APP_)
|
|
11613
|
+
* according to your project's framework/runtime (Next.js, Bun, Deno, React/Vite, etc.).
|
|
11614
|
+
*/
|
|
11612
11615
|
export const api = createIgniterClient<AppRouterType>({
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11616
|
+
baseURL: process.env.NEXT_PUBLIC_IGNITER_API_URL, // Adapt for your needs
|
|
11617
|
+
basePath: process.env.NEXT_PUBLIC_IGNITER_API_BASE_PATH,
|
|
11618
|
+
router: () => {
|
|
11619
|
+
if (typeof window === 'undefined') {
|
|
11620
|
+
return require('./igniter.router').AppRouter
|
|
11621
|
+
}
|
|
11619
11622
|
|
|
11620
|
-
|
|
11621
|
-
|
|
11623
|
+
return require('./igniter.schema').AppRouterSchema
|
|
11624
|
+
},
|
|
11622
11625
|
})
|
|
11623
11626
|
|
|
11624
11627
|
/**
|
|
@@ -11640,7 +11643,6 @@ export type ApiClient = typeof api
|
|
|
11640
11643
|
*/
|
|
11641
11644
|
export const useQueryClient = useIgniterQueryClient<AppRouterType>;
|
|
11642
11645
|
`;
|
|
11643
|
-
const filePath = path7.join(outputDir, "igniter.client.ts");
|
|
11644
11646
|
await writeFileWithHeader(filePath, content, config);
|
|
11645
11647
|
return filePath;
|
|
11646
11648
|
}
|
|
@@ -11651,7 +11653,8 @@ async function writeFileWithHeader(filePath, content, config) {
|
|
|
11651
11653
|
}
|
|
11652
11654
|
function generateFileHeader(config) {
|
|
11653
11655
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
11654
|
-
return `/* eslint-disable
|
|
11656
|
+
return `/* eslint-disable */
|
|
11657
|
+
/* prettier-ignore */
|
|
11655
11658
|
|
|
11656
11659
|
/**
|
|
11657
11660
|
* Generated by @igniter-js/cli
|
|
@@ -12487,11 +12490,12 @@ function showWelcome() {
|
|
|
12487
12490
|
console.log(import_chalk2.default.dim("This process will configure your project with everything you need."));
|
|
12488
12491
|
console.log();
|
|
12489
12492
|
}
|
|
12490
|
-
async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
12493
|
+
async function runSetupPrompts(targetDir, isExistingProject = false, cliOptions = {}) {
|
|
12491
12494
|
showWelcome();
|
|
12492
12495
|
const detectedFramework = detectFramework();
|
|
12493
12496
|
const detectedPackageManager = detectPackageManager();
|
|
12494
12497
|
const projectName = targetDir ? import_path.default.basename(import_path.default.resolve(targetDir)) : "my-igniter-app";
|
|
12498
|
+
const cliFeatures = cliOptions.features ? cliOptions.features.split(",").map((f) => f.trim()) : [];
|
|
12495
12499
|
try {
|
|
12496
12500
|
const answers = await (0, import_prompts.default)([
|
|
12497
12501
|
{
|
|
@@ -12509,8 +12513,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12509
12513
|
format: (value) => value.trim().toLowerCase().replace(/\s+/g, "-")
|
|
12510
12514
|
},
|
|
12511
12515
|
{
|
|
12512
|
-
type:
|
|
12513
|
-
// Show if not existing project OR if existing but no framework detected
|
|
12516
|
+
type: cliOptions.template || isExistingProject && detectedFramework ? null : "select",
|
|
12514
12517
|
name: "framework",
|
|
12515
12518
|
message: "\u2022 Which starter would you like to use?",
|
|
12516
12519
|
choices: [
|
|
@@ -12541,7 +12544,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12541
12544
|
]
|
|
12542
12545
|
},
|
|
12543
12546
|
{
|
|
12544
|
-
type: "multiselect",
|
|
12547
|
+
type: cliOptions.features ? null : "multiselect",
|
|
12545
12548
|
name: "features",
|
|
12546
12549
|
message: import_chalk2.default.bold("\u2022 Which Igniter.js features would you like to enable?"),
|
|
12547
12550
|
choices: [
|
|
@@ -12578,7 +12581,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12578
12581
|
instructions: import_chalk2.default.dim("Use \u2191\u2193 to navigate, space to select, enter to confirm")
|
|
12579
12582
|
},
|
|
12580
12583
|
{
|
|
12581
|
-
type: "select",
|
|
12584
|
+
type: cliOptions.database ? null : "select",
|
|
12582
12585
|
name: "database",
|
|
12583
12586
|
message: import_chalk2.default.bold("\u2022 Choose your database (optional):"),
|
|
12584
12587
|
choices: [
|
|
@@ -12602,14 +12605,18 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12602
12605
|
initial: 0
|
|
12603
12606
|
},
|
|
12604
12607
|
{
|
|
12605
|
-
type: (prev) =>
|
|
12608
|
+
type: (prev) => {
|
|
12609
|
+
if (cliOptions.docker === false) return null;
|
|
12610
|
+
const dbValue = cliOptions.database || prev;
|
|
12611
|
+
return dbValue !== "none" ? "confirm" : null;
|
|
12612
|
+
},
|
|
12606
12613
|
name: "dockerCompose",
|
|
12607
12614
|
message: import_chalk2.default.bold("\u2022 Setup Docker Compose for development?"),
|
|
12608
12615
|
hint: import_chalk2.default.dim("Includes Redis and your selected database"),
|
|
12609
|
-
initial:
|
|
12616
|
+
initial: cliOptions.docker !== false
|
|
12610
12617
|
},
|
|
12611
12618
|
{
|
|
12612
|
-
type: "select",
|
|
12619
|
+
type: cliOptions.packageManager ? null : "select",
|
|
12613
12620
|
name: "packageManager",
|
|
12614
12621
|
message: isExistingProject ? `We detected ${import_chalk2.default.cyan(detectedPackageManager)}. Please confirm or select another.` : import_chalk2.default.bold("\u2022 Which package manager?"),
|
|
12615
12622
|
choices: [
|
|
@@ -12630,19 +12637,19 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12630
12637
|
value: "bun"
|
|
12631
12638
|
}
|
|
12632
12639
|
],
|
|
12633
|
-
initial: getPackageManagerChoiceIndex(detectedPackageManager)
|
|
12640
|
+
initial: getPackageManagerChoiceIndex(cliOptions.packageManager || detectedPackageManager)
|
|
12634
12641
|
},
|
|
12635
12642
|
{
|
|
12636
|
-
type: isExistingProject ? null : "confirm",
|
|
12643
|
+
type: isExistingProject || cliOptions.git === false ? null : "confirm",
|
|
12637
12644
|
name: "initGit",
|
|
12638
12645
|
message: import_chalk2.default.bold("\u2022 Initialize Git repository?"),
|
|
12639
|
-
initial:
|
|
12646
|
+
initial: cliOptions.git !== false
|
|
12640
12647
|
},
|
|
12641
12648
|
{
|
|
12642
|
-
type: "confirm",
|
|
12649
|
+
type: cliOptions.install === false ? null : "confirm",
|
|
12643
12650
|
name: "installDependencies",
|
|
12644
12651
|
message: import_chalk2.default.bold("\u2022 Install dependencies automatically?"),
|
|
12645
|
-
initial:
|
|
12652
|
+
initial: cliOptions.install !== false
|
|
12646
12653
|
}
|
|
12647
12654
|
], {
|
|
12648
12655
|
onCancel: () => {
|
|
@@ -12650,22 +12657,24 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
|
|
|
12650
12657
|
process.exit(0);
|
|
12651
12658
|
}
|
|
12652
12659
|
});
|
|
12660
|
+
const selectedFeatures = cliOptions.features ? cliFeatures : answers.features || [];
|
|
12661
|
+
const hasExplicitFeatures = cliOptions.features || answers.features && answers.features.length > 0;
|
|
12653
12662
|
const featuresObj = {
|
|
12654
|
-
store:
|
|
12655
|
-
jobs:
|
|
12656
|
-
mcp:
|
|
12657
|
-
logging:
|
|
12658
|
-
telemetry:
|
|
12663
|
+
store: selectedFeatures.includes("store"),
|
|
12664
|
+
jobs: selectedFeatures.includes("jobs"),
|
|
12665
|
+
mcp: selectedFeatures.includes("mcp"),
|
|
12666
|
+
logging: selectedFeatures.includes("logging") || !hasExplicitFeatures,
|
|
12667
|
+
telemetry: selectedFeatures.includes("telemetry") || !hasExplicitFeatures
|
|
12659
12668
|
};
|
|
12660
12669
|
const config = {
|
|
12661
12670
|
projectName: answers.projectName || projectName,
|
|
12662
|
-
framework: answers.framework,
|
|
12671
|
+
framework: cliOptions.template || answers.framework,
|
|
12663
12672
|
features: featuresObj,
|
|
12664
|
-
database: { provider: answers.database },
|
|
12665
|
-
packageManager: answers.packageManager,
|
|
12666
|
-
initGit: answers.initGit
|
|
12667
|
-
installDependencies: answers.installDependencies,
|
|
12668
|
-
dockerCompose: answers.dockerCompose || false
|
|
12673
|
+
database: { provider: cliOptions.database || answers.database || "none" },
|
|
12674
|
+
packageManager: cliOptions.packageManager || answers.packageManager || detectedPackageManager,
|
|
12675
|
+
initGit: cliOptions.git !== false && (answers.initGit !== void 0 ? answers.initGit : !isExistingProject),
|
|
12676
|
+
installDependencies: cliOptions.install !== false && answers.installDependencies !== false,
|
|
12677
|
+
dockerCompose: cliOptions.docker !== false && (answers.dockerCompose || false)
|
|
12669
12678
|
};
|
|
12670
12679
|
showConfigSummary(config);
|
|
12671
12680
|
return config;
|
|
@@ -12726,7 +12735,7 @@ var IGNITER_FEATURES = {
|
|
|
12726
12735
|
name: "Redis Store",
|
|
12727
12736
|
description: "Caching, sessions, and pub/sub messaging",
|
|
12728
12737
|
dependencies: [
|
|
12729
|
-
{ name: "@igniter-js/adapter-redis", version: "
|
|
12738
|
+
{ name: "@igniter-js/adapter-redis", version: "latest" },
|
|
12730
12739
|
{ name: "ioredis", version: "^5.6.1" }
|
|
12731
12740
|
],
|
|
12732
12741
|
devDependencies: [
|
|
@@ -12754,8 +12763,8 @@ var IGNITER_FEATURES = {
|
|
|
12754
12763
|
name: "BullMQ Jobs",
|
|
12755
12764
|
description: "Background task processing and job queues",
|
|
12756
12765
|
dependencies: [
|
|
12757
|
-
{ name: "@igniter-js/adapter-redis", version: "
|
|
12758
|
-
{ name: "@igniter-js/adapter-bullmq", version: "
|
|
12766
|
+
{ name: "@igniter-js/adapter-redis", version: "latest" },
|
|
12767
|
+
{ name: "@igniter-js/adapter-bullmq", version: "latest" },
|
|
12759
12768
|
{ name: "bullmq", version: "^4.0.0" },
|
|
12760
12769
|
{ name: "ioredis", version: "^5.6.1" }
|
|
12761
12770
|
],
|
|
@@ -12783,7 +12792,7 @@ var IGNITER_FEATURES = {
|
|
|
12783
12792
|
name: "MCP Server",
|
|
12784
12793
|
description: "Easy expose your API as a MCP server for AI assistants like Cursor, Claude, etc.",
|
|
12785
12794
|
dependencies: [
|
|
12786
|
-
{ name: "@igniter-js/adapter-mcp", version: "
|
|
12795
|
+
{ name: "@igniter-js/adapter-mcp", version: "latest" },
|
|
12787
12796
|
{ name: "@vercel/mcp-adapter", version: "^0.2.0" },
|
|
12788
12797
|
{ name: "@modelcontextprotocol/sdk", version: "^1.10.2" },
|
|
12789
12798
|
{ name: "ioredis", version: "^5.6.1" }
|
|
@@ -12815,7 +12824,7 @@ var IGNITER_FEATURES = {
|
|
|
12815
12824
|
name: "Enhanced Logging",
|
|
12816
12825
|
description: "Advanced console logging with structured output",
|
|
12817
12826
|
dependencies: [
|
|
12818
|
-
{ name: "@igniter-js/core", version: "
|
|
12827
|
+
{ name: "@igniter-js/core", version: "latest" }
|
|
12819
12828
|
],
|
|
12820
12829
|
envVars: [
|
|
12821
12830
|
{ key: "IGNITER_LOG_LEVEL", value: "info", description: "Logging level (debug, info, warn, error)" }
|
|
@@ -12826,7 +12835,7 @@ var IGNITER_FEATURES = {
|
|
|
12826
12835
|
name: "Telemetry",
|
|
12827
12836
|
description: "Telemetry for tracking requests and errors",
|
|
12828
12837
|
dependencies: [
|
|
12829
|
-
{ name: "@igniter-js/core", version: "
|
|
12838
|
+
{ name: "@igniter-js/core", version: "latest" }
|
|
12830
12839
|
],
|
|
12831
12840
|
envVars: [
|
|
12832
12841
|
{ key: "IGNITER_TELEMETRY_ENABLE_TRACING", value: "true", description: "Enable telemetry tracing" },
|
|
@@ -14443,7 +14452,7 @@ async function handleGenerateProcedure(name, feature) {
|
|
|
14443
14452
|
// src/index.ts
|
|
14444
14453
|
var program = new import_commander.Command();
|
|
14445
14454
|
program.name("igniter").description("CLI for Igniter.js type-safe client generation").version("1.0.0");
|
|
14446
|
-
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 (
|
|
14455
|
+
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) => {
|
|
14447
14456
|
const initLogger = createChildLogger({ component: "init-command" });
|
|
14448
14457
|
try {
|
|
14449
14458
|
if (!projectName) {
|
|
@@ -14480,7 +14489,7 @@ program.command("init").description("Create a new Igniter.js project with intera
|
|
|
14480
14489
|
}
|
|
14481
14490
|
}
|
|
14482
14491
|
}
|
|
14483
|
-
const config = await runSetupPrompts(targetDir, isExistingProject);
|
|
14492
|
+
const config = await runSetupPrompts(targetDir, isExistingProject, options);
|
|
14484
14493
|
const validation = validateConfig(config);
|
|
14485
14494
|
if (!validation.isValid) {
|
|
14486
14495
|
console.error(`\u2717 ${validation.message}`);
|