@forinda/kickjs-cli 2.3.2 → 3.0.0
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 +19 -0
- package/dist/cli.mjs +849 -199
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +133 -72
- package/dist/index.mjs.map +1 -1
- package/dist/{typegen-CClCYrkk.mjs → typegen-BL0O61s-.mjs} +2 -2
- package/dist/{typegen-CClCYrkk.mjs.map → typegen-BL0O61s-.mjs.map} +1 -1
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -286,6 +286,7 @@ interface InitProjectOptions {
|
|
|
286
286
|
installDeps?: boolean;
|
|
287
287
|
template?: ProjectTemplate;
|
|
288
288
|
defaultRepo?: string;
|
|
289
|
+
packages?: string[];
|
|
289
290
|
}
|
|
290
291
|
/** Scaffold a new KickJS project */
|
|
291
292
|
declare function initProject(options: InitProjectOptions): Promise<void>;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/naming.ts"],"mappings":";;;UAIiB,qBAAA;EAAqB;EAEpC,IAAA;EAFoC;EAIpC,WAAA;EAAA;;;;;AAeF;;;EANE,KAAA;EAMwB;EAJxB,OAAA;AAAA;;KAIU,cAAA;;KAGA,iBAAA;;UAKK,cAAA;EACf,IAAA;AAAA;;KAIU,cAAA,GAAiB,iBAAA,GAAkB,cAAA;;;AAS/C;;;;;KAAY,eAAA;;UAGK,aAAA;EAuBkB;;;;EAlBjC,MAAA;EA4BA;;;AAIF;EA3BE,MAAA;;;;;;;;;;;AAiEF;;EApDE,eAAA,GAAkB,eAAA;EA6DR;;;;;;;;;EAnDV,OAAA;AAAA;;UAIe,YAAA;EAiEf;EA/DA,GAAA;EAiEA;;;;;;;;;;;;;EAnDA,IAAA,GAAO,cAAA;EAuFL;EArFF,SAAA;EAqFQ;AAKV;;;;EApFE,SAAA;EAoF2B;;;;AA6B7B;;;;;EAvGE,gBAAA;AAAA;;UAIe,UAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/naming.ts"],"mappings":"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"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli
|
|
2
|
+
* @forinda/kickjs-cli v3.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
|
12
|
-
import { createInterface } from "node:readline";
|
|
13
12
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
13
|
+
import * as clack from "@clack/prompts";
|
|
14
|
+
import pc from "picocolors";
|
|
14
15
|
import pkg from "pluralize";
|
|
15
16
|
import { execSync } from "node:child_process";
|
|
16
17
|
import { readFileSync } from "node:fs";
|
|
@@ -29,6 +30,23 @@ async function fileExists(filePath) {
|
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
33
|
+
pc.green, pc.cyan, pc.yellow, pc.magenta, pc.red;
|
|
34
|
+
pc.green("✓"), pc.red("✖"), pc.yellow("⚠"), pc.blue("ℹ");
|
|
35
|
+
/** Handle cancellation — print message and exit */
|
|
36
|
+
function handleCancel(value) {
|
|
37
|
+
if (clack.isCancel(value)) {
|
|
38
|
+
clack.cancel("Operation cancelled.");
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Yes/no confirmation prompt */
|
|
43
|
+
async function confirm(opts) {
|
|
44
|
+
const value = await clack.confirm(opts);
|
|
45
|
+
handleCancel(value);
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
/** Log utilities for styled messages inside clack flow */
|
|
49
|
+
const log = clack.log;
|
|
32
50
|
//#endregion
|
|
33
51
|
//#region src/utils/naming.ts
|
|
34
52
|
/** Convert a name to PascalCase */
|
|
@@ -1518,18 +1536,32 @@ export class Prisma${pascal}Repository implements I${pascal}Repository {
|
|
|
1518
1536
|
* In production, bootstrap() auto-starts the HTTP server when
|
|
1519
1537
|
* `globalThis.__kickjs_httpServer` is not set.
|
|
1520
1538
|
*/
|
|
1521
|
-
function generateEntryFile(name, template, version) {
|
|
1539
|
+
function generateEntryFile(name, template, version, packages = []) {
|
|
1522
1540
|
switch (template) {
|
|
1523
|
-
case "graphql":
|
|
1541
|
+
case "graphql": {
|
|
1542
|
+
const gqlImports = [];
|
|
1543
|
+
const gqlAdapters = [];
|
|
1544
|
+
if (packages.includes("devtools")) {
|
|
1545
|
+
gqlImports.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`);
|
|
1546
|
+
gqlAdapters.push(` new DevToolsAdapter(),`);
|
|
1547
|
+
}
|
|
1548
|
+
if (packages.includes("otel")) {
|
|
1549
|
+
gqlImports.push(`import { OtelAdapter } from '@forinda/kickjs-otel'`);
|
|
1550
|
+
gqlAdapters.push(` new OtelAdapter({ serviceName: '${name}' }),`);
|
|
1551
|
+
}
|
|
1552
|
+
if (packages.includes("swagger")) {
|
|
1553
|
+
gqlImports.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`);
|
|
1554
|
+
gqlAdapters.push(` new SwaggerAdapter({ info: { title: '${name}', version: '${version}' } }),`);
|
|
1555
|
+
}
|
|
1556
|
+
return `import 'reflect-metadata'
|
|
1524
1557
|
// Side-effect import — registers the extended env schema with kickjs
|
|
1525
1558
|
// **before** any controller / service / @Value gets resolved. Without
|
|
1526
1559
|
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
1527
1560
|
// cached schema would still be the base shape. See guide/configuration.
|
|
1528
1561
|
import './config'
|
|
1529
1562
|
import { bootstrap } from '@forinda/kickjs'
|
|
1530
|
-
import { DevToolsAdapter } from '@forinda/kickjs-devtools'
|
|
1531
1563
|
import { GraphQLAdapter } from '@forinda/kickjs-graphql'
|
|
1532
|
-
import { modules } from './modules'
|
|
1564
|
+
${gqlImports.length ? gqlImports.join("\n") + "\n" : ""}import { modules } from './modules'
|
|
1533
1565
|
|
|
1534
1566
|
// Import your resolvers here
|
|
1535
1567
|
// import { UserResolver } from './resolvers/user.resolver'
|
|
@@ -1538,8 +1570,7 @@ import { modules } from './modules'
|
|
|
1538
1570
|
export const app = await bootstrap({
|
|
1539
1571
|
modules,
|
|
1540
1572
|
adapters: [
|
|
1541
|
-
new
|
|
1542
|
-
new GraphQLAdapter({
|
|
1573
|
+
${gqlAdapters.length ? gqlAdapters.join("\n") + "\n" : ""} new GraphQLAdapter({
|
|
1543
1574
|
resolvers: [/* UserResolver */],
|
|
1544
1575
|
// Add custom type definitions here:
|
|
1545
1576
|
// typeDefs: userTypeDefs,
|
|
@@ -1547,51 +1578,91 @@ export const app = await bootstrap({
|
|
|
1547
1578
|
],
|
|
1548
1579
|
})
|
|
1549
1580
|
`;
|
|
1550
|
-
|
|
1581
|
+
}
|
|
1582
|
+
case "cqrs": {
|
|
1583
|
+
const cqrsImports = [];
|
|
1584
|
+
const cqrsAdapters = [];
|
|
1585
|
+
if (packages.includes("otel")) {
|
|
1586
|
+
cqrsImports.push(`import { OtelAdapter } from '@forinda/kickjs-otel'`);
|
|
1587
|
+
cqrsAdapters.push(` new OtelAdapter({ serviceName: '${name}' }),`);
|
|
1588
|
+
}
|
|
1589
|
+
if (packages.includes("devtools")) {
|
|
1590
|
+
cqrsImports.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`);
|
|
1591
|
+
cqrsAdapters.push(` new DevToolsAdapter(),`);
|
|
1592
|
+
}
|
|
1593
|
+
if (packages.includes("swagger")) {
|
|
1594
|
+
cqrsImports.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`);
|
|
1595
|
+
cqrsAdapters.push(` new SwaggerAdapter({\n info: { title: '${name}', version: '${version}' },\n }),`);
|
|
1596
|
+
}
|
|
1597
|
+
if (packages.includes("graphql")) {
|
|
1598
|
+
cqrsImports.push(`import { GraphQLAdapter } from '@forinda/kickjs-graphql'`);
|
|
1599
|
+
cqrsAdapters.push(` new GraphQLAdapter({ resolvers: [] }),`);
|
|
1600
|
+
}
|
|
1601
|
+
return `import 'reflect-metadata'
|
|
1551
1602
|
// Side-effect import — registers the extended env schema with kickjs
|
|
1552
1603
|
// **before** any controller / service / @Value gets resolved. Without
|
|
1553
1604
|
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
1554
1605
|
// cached schema would still be the base shape. See guide/configuration.
|
|
1555
1606
|
import './config'
|
|
1556
1607
|
import { bootstrap } from '@forinda/kickjs'
|
|
1557
|
-
import { DevToolsAdapter } from '@forinda/kickjs-devtools'
|
|
1558
|
-
import { SwaggerAdapter } from '@forinda/kickjs-swagger'
|
|
1559
|
-
import { OtelAdapter } from '@forinda/kickjs-otel'
|
|
1560
1608
|
// import { WsAdapter } from '@forinda/kickjs-ws'
|
|
1561
1609
|
// import { QueueAdapter, BullMQProvider } from '@forinda/kickjs-queue'
|
|
1562
|
-
import { modules } from './modules'
|
|
1610
|
+
${cqrsImports.length ? cqrsImports.join("\n") + "\n" : ""}import { modules } from './modules'
|
|
1563
1611
|
|
|
1564
1612
|
// Export the app for the Vite plugin (dev mode)
|
|
1565
1613
|
export const app = await bootstrap({
|
|
1566
|
-
modules,
|
|
1567
|
-
adapters: [
|
|
1568
|
-
new OtelAdapter({ serviceName: '${name}' }),
|
|
1569
|
-
new DevToolsAdapter(),
|
|
1570
|
-
new SwaggerAdapter({
|
|
1571
|
-
info: { title: '${name}', version: '${version}' },
|
|
1572
|
-
}),
|
|
1573
|
-
// Uncomment for WebSocket support:
|
|
1574
|
-
// new WsAdapter(),
|
|
1575
|
-
// Uncomment when Redis is available:
|
|
1576
|
-
// new QueueAdapter({
|
|
1577
|
-
// provider: new BullMQProvider({ host: 'localhost', port: 6379 }),
|
|
1578
|
-
// }),
|
|
1579
|
-
],
|
|
1614
|
+
modules,${cqrsImports.length ? `\n adapters: [\n${cqrsAdapters.join("\n")}\n // Uncomment for WebSocket support:\n // new WsAdapter(),\n // Uncomment when Redis is available:\n // new QueueAdapter({\n // provider: new BullMQProvider({ host: 'localhost', port: 6379 }),\n // }),\n ],` : `\n adapters: [\n // Uncomment for WebSocket support:\n // new WsAdapter(),\n // Uncomment when Redis is available:\n // new QueueAdapter({\n // provider: new BullMQProvider({ host: 'localhost', port: 6379 }),\n // }),\n ],`}
|
|
1580
1615
|
})
|
|
1581
1616
|
`;
|
|
1582
|
-
|
|
1617
|
+
}
|
|
1618
|
+
case "minimal": {
|
|
1619
|
+
const imports = [];
|
|
1620
|
+
const adapters = [];
|
|
1621
|
+
if (packages.includes("swagger")) {
|
|
1622
|
+
imports.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`);
|
|
1623
|
+
adapters.push(` new SwaggerAdapter({ info: { title: '${name}', version: '${version}' } }),`);
|
|
1624
|
+
}
|
|
1625
|
+
if (packages.includes("devtools")) {
|
|
1626
|
+
imports.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`);
|
|
1627
|
+
adapters.push(` new DevToolsAdapter(),`);
|
|
1628
|
+
}
|
|
1629
|
+
if (packages.includes("otel")) {
|
|
1630
|
+
imports.push(`import { OtelAdapter } from '@forinda/kickjs-otel'`);
|
|
1631
|
+
adapters.push(` new OtelAdapter({ serviceName: '${name}' }),`);
|
|
1632
|
+
}
|
|
1633
|
+
if (packages.includes("graphql")) {
|
|
1634
|
+
imports.push(`import { GraphQLAdapter } from '@forinda/kickjs-graphql'`);
|
|
1635
|
+
adapters.push(` new GraphQLAdapter({ resolvers: [] }),`);
|
|
1636
|
+
}
|
|
1637
|
+
return `import 'reflect-metadata'
|
|
1583
1638
|
// Side-effect import — registers the extended env schema with kickjs
|
|
1584
1639
|
// **before** any controller / service / @Value gets resolved. Without
|
|
1585
1640
|
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
1586
1641
|
// cached schema would still be the base shape. See guide/configuration.
|
|
1587
1642
|
import './config'
|
|
1588
1643
|
import { bootstrap } from '@forinda/kickjs'
|
|
1589
|
-
import { modules } from './modules'
|
|
1644
|
+
${imports.length ? imports.join("\n") + "\n" : ""}import { modules } from './modules'
|
|
1590
1645
|
|
|
1591
1646
|
// Export the app for the Vite plugin (dev mode)
|
|
1592
|
-
export const app = await bootstrap({ modules })
|
|
1647
|
+
export const app = await bootstrap({ modules${adapters.length ? `,\n adapters: [\n${adapters.join("\n")}\n ]` : ""} })
|
|
1593
1648
|
`;
|
|
1594
|
-
|
|
1649
|
+
}
|
|
1650
|
+
default: {
|
|
1651
|
+
const restImports = [];
|
|
1652
|
+
const restAdapters = [];
|
|
1653
|
+
if (packages.includes("devtools")) {
|
|
1654
|
+
restImports.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`);
|
|
1655
|
+
restAdapters.push(` new DevToolsAdapter(),`);
|
|
1656
|
+
}
|
|
1657
|
+
if (packages.includes("swagger")) {
|
|
1658
|
+
restImports.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`);
|
|
1659
|
+
restAdapters.push(` new SwaggerAdapter({\n info: { title: '${name}', version: '${version}' },\n }),`);
|
|
1660
|
+
}
|
|
1661
|
+
if (packages.includes("otel")) {
|
|
1662
|
+
restImports.push(`import { OtelAdapter } from '@forinda/kickjs-otel'`);
|
|
1663
|
+
restAdapters.push(` new OtelAdapter({ serviceName: '${name}' }),`);
|
|
1664
|
+
}
|
|
1665
|
+
return `import 'reflect-metadata'
|
|
1595
1666
|
// Side-effect import — registers the extended env schema with kickjs
|
|
1596
1667
|
// **before** any controller / service / @Value gets resolved. Without
|
|
1597
1668
|
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
@@ -1605,19 +1676,11 @@ import {
|
|
|
1605
1676
|
helmet,
|
|
1606
1677
|
cors,
|
|
1607
1678
|
} from '@forinda/kickjs'
|
|
1608
|
-
import {
|
|
1609
|
-
import { SwaggerAdapter } from '@forinda/kickjs-swagger'
|
|
1610
|
-
import { modules } from './modules'
|
|
1679
|
+
${restImports.length ? restImports.join("\n") + "\n" : ""}import { modules } from './modules'
|
|
1611
1680
|
|
|
1612
1681
|
// Export the app for the Vite plugin (dev mode)
|
|
1613
1682
|
export const app = await bootstrap({
|
|
1614
|
-
modules
|
|
1615
|
-
adapters: [
|
|
1616
|
-
new DevToolsAdapter(),
|
|
1617
|
-
new SwaggerAdapter({
|
|
1618
|
-
info: { title: '${name}', version: '${version}' },
|
|
1619
|
-
}),
|
|
1620
|
-
],
|
|
1683
|
+
modules,${restAdapters.length ? `\n adapters: [\n${restAdapters.join("\n")}\n ],` : ""}
|
|
1621
1684
|
middleware: [
|
|
1622
1685
|
helmet(),
|
|
1623
1686
|
cors({ origin: '*' }),
|
|
@@ -1627,6 +1690,7 @@ export const app = await bootstrap({
|
|
|
1627
1690
|
],
|
|
1628
1691
|
})
|
|
1629
1692
|
`;
|
|
1693
|
+
}
|
|
1630
1694
|
}
|
|
1631
1695
|
}
|
|
1632
1696
|
/** Generate src/modules/index.ts module registry */
|
|
@@ -2142,19 +2206,6 @@ async function generateDddFiles(ctx) {
|
|
|
2142
2206
|
}
|
|
2143
2207
|
//#endregion
|
|
2144
2208
|
//#region src/generators/module.ts
|
|
2145
|
-
/** Prompt the user for a single-line answer via stdin */
|
|
2146
|
-
function promptUser(question) {
|
|
2147
|
-
const rl = createInterface({
|
|
2148
|
-
input: process.stdin,
|
|
2149
|
-
output: process.stdout
|
|
2150
|
-
});
|
|
2151
|
-
return new Promise((resolve) => {
|
|
2152
|
-
rl.question(question, (answer) => {
|
|
2153
|
-
rl.close();
|
|
2154
|
-
resolve(answer.trim().toLowerCase());
|
|
2155
|
-
});
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
2209
|
/**
|
|
2159
2210
|
* Generate a module — structure depends on the project pattern.
|
|
2160
2211
|
*
|
|
@@ -2184,10 +2235,11 @@ async function generateModule(options) {
|
|
|
2184
2235
|
return;
|
|
2185
2236
|
}
|
|
2186
2237
|
if (!overwriteAll && await fileExists(fullPath)) {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2238
|
+
if (!await confirm({
|
|
2239
|
+
message: `File exists: ${pc.dim(relativePath)}. Overwrite?`,
|
|
2240
|
+
initialValue: false
|
|
2241
|
+
})) {
|
|
2242
|
+
log.warn(`Skipped: ${relativePath}`);
|
|
2191
2243
|
return;
|
|
2192
2244
|
}
|
|
2193
2245
|
}
|
|
@@ -2613,8 +2665,22 @@ export type ${pascal}DTO = z.infer<typeof ${camel}Schema>
|
|
|
2613
2665
|
}
|
|
2614
2666
|
//#endregion
|
|
2615
2667
|
//#region src/generators/templates/project-config.ts
|
|
2668
|
+
/** Map of optional package names to their npm package identifiers */
|
|
2669
|
+
const PACKAGE_DEPS = {
|
|
2670
|
+
auth: "@forinda/kickjs-auth",
|
|
2671
|
+
swagger: "@forinda/kickjs-swagger",
|
|
2672
|
+
otel: "@forinda/kickjs-otel",
|
|
2673
|
+
ws: "@forinda/kickjs-ws",
|
|
2674
|
+
queue: "@forinda/kickjs-queue",
|
|
2675
|
+
cron: "@forinda/kickjs-cron",
|
|
2676
|
+
mailer: "@forinda/kickjs-mailer",
|
|
2677
|
+
graphql: "@forinda/kickjs-graphql",
|
|
2678
|
+
devtools: "@forinda/kickjs-devtools",
|
|
2679
|
+
notifications: "@forinda/kickjs-notifications",
|
|
2680
|
+
"multi-tenant": "@forinda/kickjs-multi-tenant"
|
|
2681
|
+
};
|
|
2616
2682
|
/** Generate package.json with template-aware dependencies */
|
|
2617
|
-
function generatePackageJson(name, template, kickjsVersion) {
|
|
2683
|
+
function generatePackageJson(name, template, kickjsVersion, packages = []) {
|
|
2618
2684
|
const baseDeps = {
|
|
2619
2685
|
"@forinda/kickjs": kickjsVersion,
|
|
2620
2686
|
dotenv: "^17.3.1",
|
|
@@ -2624,20 +2690,15 @@ function generatePackageJson(name, template, kickjsVersion) {
|
|
|
2624
2690
|
pino: "^10.3.1",
|
|
2625
2691
|
"pino-pretty": "^13.1.3"
|
|
2626
2692
|
};
|
|
2627
|
-
if (template !== "minimal") {
|
|
2628
|
-
baseDeps["@forinda/kickjs-swagger"] = kickjsVersion;
|
|
2629
|
-
baseDeps["@forinda/kickjs-devtools"] = kickjsVersion;
|
|
2630
|
-
}
|
|
2631
2693
|
if (template === "graphql") {
|
|
2632
2694
|
baseDeps["@forinda/kickjs-graphql"] = kickjsVersion;
|
|
2633
2695
|
baseDeps["graphql"] = "^16.11.0";
|
|
2634
2696
|
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
baseDeps[
|
|
2638
|
-
baseDeps["@forinda/kickjs-otel"] = kickjsVersion;
|
|
2697
|
+
for (const pkg of packages) {
|
|
2698
|
+
const dep = PACKAGE_DEPS[pkg];
|
|
2699
|
+
if (dep && !baseDeps[dep]) baseDeps[dep] = kickjsVersion;
|
|
2639
2700
|
}
|
|
2640
|
-
if (
|
|
2701
|
+
if (packages.includes("graphql") && !baseDeps["graphql"]) baseDeps["graphql"] = "^16.11.0";
|
|
2641
2702
|
return JSON.stringify({
|
|
2642
2703
|
name,
|
|
2643
2704
|
version: kickjsVersion.replace("^", ""),
|
|
@@ -3668,11 +3729,11 @@ const cliPkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "u
|
|
|
3668
3729
|
const KICKJS_VERSION = `^${cliPkg.version}`;
|
|
3669
3730
|
/** Scaffold a new KickJS project */
|
|
3670
3731
|
async function initProject(options) {
|
|
3671
|
-
const { name, directory, packageManager = "pnpm", template = "rest", defaultRepo = "inmemory" } = options;
|
|
3732
|
+
const { name, directory, packageManager = "pnpm", template = "rest", defaultRepo = "inmemory", packages = [] } = options;
|
|
3672
3733
|
const dir = directory;
|
|
3673
3734
|
const log = (msg) => console.log(` ${msg}`);
|
|
3674
3735
|
console.log(`\n Creating KickJS project: ${name}\n`);
|
|
3675
|
-
await writeFileSafe(join(dir, "package.json"), generatePackageJson(name, template, KICKJS_VERSION));
|
|
3736
|
+
await writeFileSafe(join(dir, "package.json"), generatePackageJson(name, template, KICKJS_VERSION, packages));
|
|
3676
3737
|
await writeFileSafe(join(dir, "vite.config.ts"), generateViteConfig());
|
|
3677
3738
|
await writeFileSafe(join(dir, "tsconfig.json"), generateTsConfig());
|
|
3678
3739
|
await writeFileSafe(join(dir, ".prettierrc"), generatePrettierConfig());
|
|
@@ -3682,7 +3743,7 @@ async function initProject(options) {
|
|
|
3682
3743
|
await writeFileSafe(join(dir, ".env"), generateEnv());
|
|
3683
3744
|
await writeFileSafe(join(dir, ".env.example"), generateEnvExample());
|
|
3684
3745
|
await writeFileSafe(join(dir, "src/config/index.ts"), generateEnvFile());
|
|
3685
|
-
await writeFileSafe(join(dir, "src/index.ts"), generateEntryFile(name, template, cliPkg.version));
|
|
3746
|
+
await writeFileSafe(join(dir, "src/index.ts"), generateEntryFile(name, template, cliPkg.version, packages));
|
|
3686
3747
|
await writeFileSafe(join(dir, "src/modules/index.ts"), generateModulesIndex());
|
|
3687
3748
|
await writeFileSafe(join(dir, "src/modules/hello/hello.service.ts"), generateHelloService());
|
|
3688
3749
|
await writeFileSafe(join(dir, "src/modules/hello/hello.controller.ts"), generateHelloController());
|
|
@@ -3706,7 +3767,7 @@ async function initProject(options) {
|
|
|
3706
3767
|
}
|
|
3707
3768
|
}
|
|
3708
3769
|
try {
|
|
3709
|
-
const { runTypegen } = await import("./typegen-
|
|
3770
|
+
const { runTypegen } = await import("./typegen-BL0O61s-.mjs");
|
|
3710
3771
|
await runTypegen({
|
|
3711
3772
|
cwd: dir,
|
|
3712
3773
|
allowDuplicates: true,
|