create-baeta 2.0.0-next.11 → 2.0.0-next.12

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # create-baeta
2
2
 
3
+ ## 2.0.0-next.12
4
+
3
5
  ## 2.0.0-next.11
4
6
 
5
7
  ## 2.0.0-next.10
package/dist/cli.js CHANGED
@@ -1,17 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { d as packageManagers, t as handler } from "./handler-gi3zJbO5.js";
2
+ import { d as packageManagers, t as handler } from "./handler-CrK2lbPA.js";
3
3
  import { logger } from "@docusaurus/logger";
4
4
  import semver from "semver";
5
5
  import yargs from "yargs";
6
6
  import { hideBin } from "yargs/helpers";
7
-
8
7
  //#region package.json
9
- var version = "2.0.0-next.11";
10
- var engines = { "node": ">=22.20.0" };
11
-
8
+ var version = "2.0.0-next.12";
12
9
  //#endregion
13
10
  //#region cli.ts
14
- const requiredVersion = engines.node;
11
+ const requiredVersion = { "node": ">=22.20.0" }.node;
15
12
  if (!semver.satisfies(process.version, requiredVersion)) {
16
13
  logger.error("Minimum Node.js version not met :(");
17
14
  logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
@@ -24,8 +21,8 @@ process.on("unhandledRejection", (err) => {
24
21
  yargs(hideBin(process.argv)).version(version).command({
25
22
  command: "* [appName] [template] [rootDir]",
26
23
  describe: "Initialize Baeta application",
27
- builder: (yargs$1) => {
28
- return yargs$1.option("package-manager", {
24
+ builder: (yargs) => {
25
+ return yargs.option("package-manager", {
29
26
  alias: "p",
30
27
  describe: "The package manager used to install dependencies.",
31
28
  type: "string",
@@ -49,7 +46,7 @@ yargs(hideBin(process.argv)).version(version).command({
49
46
  },
50
47
  handler: (argv) => handler(argv)
51
48
  }).showHelpOnFail(true).strict().help().parse();
52
-
53
49
  //#endregion
54
- export { };
50
+ export {};
51
+
55
52
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["yargs"],"sources":["../package.json","../cli.ts"],"sourcesContent":["{\n \"name\": \"create-baeta\",\n \"version\": \"2.0.0-next.11\",\n \"keywords\": [\n \"baeta\",\n \"graphql\",\n \"schema\",\n \"types\",\n \"typescript\",\n \"framework\",\n \"builder\"\n ],\n \"homepage\": \"https://github.com/andreisergiu98/baeta#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/andreisergiu98/baeta/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/andreisergiu98/baeta.git\",\n \"directory\": \"packages/create-baeta\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"Andrei Pampu\",\n \"url\": \"https://github.com/andreisergiu98\"\n },\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./index.ts\",\n \"default\": \"./index.ts\"\n }\n },\n \"types\": \"dist/index.d.ts\",\n \"bin\": \"dist/cli.js\",\n \"files\": [\n \"dist\",\n \"templates\",\n \"package.json\"\n ],\n \"scripts\": {\n \"prebuild\": \"node --no-warnings --experimental-transform-types ./scripts/version-manifest.ts\",\n \"build\": \"yarn prebuild && builder build\",\n \"prepack\": \"builder prepare\",\n \"postpack\": \"builder prepare --clean\",\n \"test\": \"builder test\",\n \"test:circular\": \"builder test-circular\",\n \"types\": \"yarn prebuild && tsc --noEmit\"\n },\n \"ava\": {\n \"extensions\": {\n \"ts\": \"module\"\n }\n },\n \"dependencies\": {\n \"@docusaurus/logger\": \"^3.9.2\",\n \"fs-extra\": \"^11.3.2\",\n \"prompts\": \"^2.4.2\",\n \"semver\": \"^7.7.3\",\n \"shelljs\": \"^0.10.0\",\n \"supports-color\": \"^10.2.2\",\n \"yargs\": \"^18.0.0\"\n },\n \"devDependencies\": {\n \"@baeta/builder\": \"workspace:^\",\n \"@baeta/testing\": \"workspace:^\",\n \"@baeta/tsconfig\": \"workspace:^\",\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/node\": \"^22.19.1\",\n \"@types/prompts\": \"^2.4.9\",\n \"@types/semver\": \"^7.7.1\",\n \"@types/shelljs\": \"^0.8.17\",\n \"@types/yargs\": \"^17.0.35\",\n \"typescript\": \"^5.9.3\"\n },\n \"engines\": {\n \"node\": \">=22.20.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n }\n },\n \"typedocOptions\": {\n \"entryPoints\": [\n \"./index.ts\"\n ],\n \"readme\": \"none\",\n \"tsconfig\": \"./tsconfig.json\",\n \"sort\": [\n \"kind\",\n \"instance-first\",\n \"required-first\",\n \"alphabetical-ignoring-documents\"\n ]\n }\n}\n","#!/usr/bin/env node\n\nimport { logger } from '@docusaurus/logger';\nimport semver from 'semver';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { packageManagers } from './lib/constants.ts';\nimport { handler } from './lib/handler.ts';\nimport { engines, version } from './package.json';\n\nconst requiredVersion = engines.node;\n\nif (!semver.satisfies(process.version, requiredVersion)) {\n\tlogger.error('Minimum Node.js version not met :(');\n\tlogger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;\n\tprocess.exit(1);\n}\n\nprocess.on('unhandledRejection', (err) => {\n\tlogger.error(err);\n\tprocess.exit(1);\n});\n\nyargs(hideBin(process.argv))\n\t.version(version)\n\t.command({\n\t\tcommand: '* [appName] [template] [rootDir]',\n\t\tdescribe: 'Initialize Baeta application',\n\t\tbuilder: (yargs) => {\n\t\t\treturn yargs\n\t\t\t\t.option('package-manager', {\n\t\t\t\t\talias: 'p',\n\t\t\t\t\tdescribe: 'The package manager used to install dependencies.',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tchoices: packageManagers,\n\t\t\t\t})\n\t\t\t\t.option('skip-install', {\n\t\t\t\t\talias: 's',\n\t\t\t\t\tdescribe: 'Do not run package manager immediately after scaffolding',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t})\n\t\t\t\t.positional('appName', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Name of the app',\n\t\t\t\t})\n\t\t\t\t.positional('template', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Template to use',\n\t\t\t\t\tchoices: ['yoga', 'apollo'],\n\t\t\t\t})\n\t\t\t\t.positional('rootDir', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Root directory',\n\t\t\t\t\tdefault: '.',\n\t\t\t\t});\n\t\t},\n\t\thandler: (argv) => handler(argv),\n\t})\n\t.showHelpOnFail(true)\n\t.strict()\n\t.help()\n\t.parse();\n"],"mappings":";;;;;;;;cAEa;cAyEA,EACT,QAAQ,aACT;;;;ACnEH,MAAM,kBAAkB,QAAQ;AAEhC,IAAI,CAAC,OAAO,UAAU,QAAQ,SAAS,gBAAgB,EAAE;AACxD,QAAO,MAAM,qCAAqC;AAClD,QAAO,IAAI,gCAAgC,QAAQ,QAAQ,gCAAgC,gBAAgB;AAC3G,SAAQ,KAAK,EAAE;;AAGhB,QAAQ,GAAG,uBAAuB,QAAQ;AACzC,QAAO,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACd;AAEF,MAAM,QAAQ,QAAQ,KAAK,CAAC,CAC1B,QAAQ,QAAQ,CAChB,QAAQ;CACR,SAAS;CACT,UAAU;CACV,UAAU,YAAU;AACnB,SAAOA,QACL,OAAO,mBAAmB;GAC1B,OAAO;GACP,UAAU;GACV,MAAM;GACN,SAAS;GACT,CAAC,CACD,OAAO,gBAAgB;GACvB,OAAO;GACP,UAAU;GACV,MAAM;GACN,CAAC,CACD,WAAW,WAAW;GACtB,MAAM;GACN,UAAU;GACV,CAAC,CACD,WAAW,YAAY;GACvB,MAAM;GACN,UAAU;GACV,SAAS,CAAC,QAAQ,SAAS;GAC3B,CAAC,CACD,WAAW,WAAW;GACtB,MAAM;GACN,UAAU;GACV,SAAS;GACT,CAAC;;CAEJ,UAAU,SAAS,QAAQ,KAAK;CAChC,CAAC,CACD,eAAe,KAAK,CACpB,QAAQ,CACR,MAAM,CACN,OAAO"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../package.json","../cli.ts"],"sourcesContent":["","#!/usr/bin/env node\n\nimport { logger } from '@docusaurus/logger';\nimport semver from 'semver';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { packageManagers } from './lib/constants.ts';\nimport { handler } from './lib/handler.ts';\nimport { engines, version } from './package.json';\n\nconst requiredVersion = engines.node;\n\nif (!semver.satisfies(process.version, requiredVersion)) {\n\tlogger.error('Minimum Node.js version not met :(');\n\tlogger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;\n\tprocess.exit(1);\n}\n\nprocess.on('unhandledRejection', (err) => {\n\tlogger.error(err);\n\tprocess.exit(1);\n});\n\nyargs(hideBin(process.argv))\n\t.version(version)\n\t.command({\n\t\tcommand: '* [appName] [template] [rootDir]',\n\t\tdescribe: 'Initialize Baeta application',\n\t\tbuilder: (yargs) => {\n\t\t\treturn yargs\n\t\t\t\t.option('package-manager', {\n\t\t\t\t\talias: 'p',\n\t\t\t\t\tdescribe: 'The package manager used to install dependencies.',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tchoices: packageManagers,\n\t\t\t\t})\n\t\t\t\t.option('skip-install', {\n\t\t\t\t\talias: 's',\n\t\t\t\t\tdescribe: 'Do not run package manager immediately after scaffolding',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t})\n\t\t\t\t.positional('appName', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Name of the app',\n\t\t\t\t})\n\t\t\t\t.positional('template', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Template to use',\n\t\t\t\t\tchoices: ['yoga', 'apollo'],\n\t\t\t\t})\n\t\t\t\t.positional('rootDir', {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescribe: 'Root directory',\n\t\t\t\t\tdefault: '.',\n\t\t\t\t});\n\t\t},\n\t\thandler: (argv) => handler(argv),\n\t})\n\t.showHelpOnFail(true)\n\t.strict()\n\t.help()\n\t.parse();\n"],"mappings":";;;;;;;;;;ACUA,MAAM,0CAA0B;AAEhC,IAAI,CAAC,OAAO,UAAU,QAAQ,SAAS,gBAAgB,EAAE;AACxD,QAAO,MAAM,qCAAqC;AAClD,QAAO,IAAI,gCAAgC,QAAQ,QAAQ,gCAAgC,gBAAgB;AAC3G,SAAQ,KAAK,EAAE;;AAGhB,QAAQ,GAAG,uBAAuB,QAAQ;AACzC,QAAO,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACd;AAEF,MAAM,QAAQ,QAAQ,KAAK,CAAC,CAC1B,QAAQ,QAAQ,CAChB,QAAQ;CACR,SAAS;CACT,UAAU;CACV,UAAU,UAAU;AACnB,SAAO,MACL,OAAO,mBAAmB;GAC1B,OAAO;GACP,UAAU;GACV,MAAM;GACN,SAAS;GACT,CAAC,CACD,OAAO,gBAAgB;GACvB,OAAO;GACP,UAAU;GACV,MAAM;GACN,CAAC,CACD,WAAW,WAAW;GACtB,MAAM;GACN,UAAU;GACV,CAAC,CACD,WAAW,YAAY;GACvB,MAAM;GACN,UAAU;GACV,SAAS,CAAC,QAAQ,SAAS;GAC3B,CAAC,CACD,WAAW,WAAW;GACtB,MAAM;GACN,UAAU;GACV,SAAS;GACT,CAAC;;CAEJ,UAAU,SAAS,QAAQ,KAAK;CAChC,CAAC,CACD,eAAe,KAAK,CACpB,QAAQ,CACR,MAAM,CACN,OAAO"}
@@ -4,7 +4,6 @@ import shell from "shelljs";
4
4
  import supportsColor from "supports-color";
5
5
  import fs from "fs-extra";
6
6
  import prompts from "prompts";
7
-
8
7
  //#region lib/constants.ts
9
8
  const defaultPackageManager = "npm";
10
9
  const lockfileNames = {
@@ -21,7 +20,6 @@ const runtimes = [
21
20
  ];
22
21
  const defaultJavaScriptRuntime = "node";
23
22
  const templates = ["yoga", "apollo"];
24
-
25
23
  //#endregion
26
24
  //#region lib/app-name.ts
27
25
  async function getAppName(reqName, rootDir) {
@@ -47,7 +45,6 @@ async function getAppName(reqName, rootDir) {
47
45
  process.exit(1);
48
46
  } }).then((result) => result.appName);
49
47
  }
50
-
51
48
  //#endregion
52
49
  //#region lib/package-manager.ts
53
50
  async function findPackageManagerFromLockFile(rootDir) {
@@ -78,8 +75,8 @@ async function askForPackageManagerChoice() {
78
75
  value: p
79
76
  }))
80
77
  }, { onCancel() {
81
- logger.info`Falling back to name=${defaultPackageManager}`;
82
- } }).then((result) => result.packageManager) ?? defaultPackageManager;
78
+ logger.info`Falling back to name=${"npm"}`;
79
+ } }).then((result) => result.packageManager) ?? "npm";
83
80
  }
84
81
  async function getPackageManager(dest, { packageManager, skipInstall }) {
85
82
  if (packageManager && !packageManagers.includes(packageManager)) throw new Error(`Invalid package manager choice ${packageManager}. Must be one of ${packageManagers.join(", ")}`);
@@ -90,7 +87,7 @@ async function getPackageManager(dest, { packageManager, skipInstall }) {
90
87
  if (fromLockfileInCwd) return fromLockfileInCwd;
91
88
  const fromUserAgent = findPackageManagerFromUserAgent();
92
89
  if (fromUserAgent) return fromUserAgent;
93
- if (skipInstall) return defaultPackageManager;
90
+ if (skipInstall) return "npm";
94
91
  return askForPackageManagerChoice();
95
92
  }
96
93
  function getInstallCommand(pkgManager) {
@@ -98,7 +95,6 @@ function getInstallCommand(pkgManager) {
98
95
  if (pkgManager === "bun") return "bun install";
99
96
  return `${pkgManager} install --color always`;
100
97
  }
101
-
102
98
  //#endregion
103
99
  //#region lib/runtime.ts
104
100
  async function getRuntime() {
@@ -118,10 +114,9 @@ async function getRuntime() {
118
114
  value: p
119
115
  }))
120
116
  }, { onCancel() {
121
- logger.info`Falling back to name=${defaultJavaScriptRuntime}`;
122
- } }).then((result) => result.runtime) ?? defaultJavaScriptRuntime;
117
+ logger.info`Falling back to name=${"node"}`;
118
+ } }).then((result) => result.runtime) ?? "node";
123
119
  }
124
-
125
120
  //#endregion
126
121
  //#region meta/apollo/package.json
127
122
  var package_default$1 = {
@@ -134,21 +129,36 @@ var package_default$1 = {
134
129
  "start": "baeta generate --watch --run='node --watch --enable-source-maps --inspect src/app.ts'"
135
130
  },
136
131
  dependencies: {
137
- "@apollo/server": "^5.2.0",
132
+ "@apollo/server": "^5.5.0",
138
133
  "@baeta/core": "workspace:^",
139
134
  "@baeta/errors": "workspace:^",
140
135
  "@baeta/extension-complexity": "workspace:^",
141
- "graphql": "^16.12.0"
136
+ "graphql": "catalog:dev"
142
137
  },
143
138
  devDependencies: {
144
139
  "@baeta/cli": "workspace:^",
145
- "@types/bun": "^1.3.3",
140
+ "@types/bun": "^1.3.11",
146
141
  "@types/deno": "^2.5.0",
147
- "@types/node": "^22.19.1",
148
- "typescript": "^5.9.3"
142
+ "@types/node": "catalog:dev",
143
+ "typescript": "catalog:dev"
149
144
  }
150
145
  };
151
-
146
+ //#endregion
147
+ //#region versions.apollo.json
148
+ var versions_apollo_default = {
149
+ dependencies: {
150
+ "@baeta/core": "^2.0.0-next.12",
151
+ "@baeta/errors": "^2.0.0-next.12",
152
+ "@baeta/extension-complexity": "^2.0.0-next.12",
153
+ "graphql": "^16.6.0"
154
+ },
155
+ devDependencies: {
156
+ "@baeta/cli": "^2.0.0-next.12",
157
+ "@types/node": "^22.19.13",
158
+ "typescript": "^5.9.3"
159
+ },
160
+ peerDependencies: {}
161
+ };
152
162
  //#endregion
153
163
  //#region ../../tools/tsconfig/tsconfig.json
154
164
  var compilerOptions = {
@@ -173,46 +183,11 @@ var tsconfig_default = {
173
183
  $schema: "https://json.schemastore.org/tsconfig",
174
184
  compilerOptions
175
185
  };
176
-
177
- //#endregion
178
- //#region versions.json
179
- var versions_default = {
180
- "@baeta/cli": "2.0.0-next.11",
181
- "@baeta/core": "2.0.0-next.11",
182
- "create-baeta": "2.0.0-next.11",
183
- "@baeta/directives": "2.0.0-next.11",
184
- "@baeta/env": "2.0.0-next.11",
185
- "@baeta/errors": "2.0.0-next.11",
186
- "@baeta/extension-auth": "2.0.0-next.11",
187
- "@baeta/extension-cache": "2.0.0-next.11",
188
- "@baeta/extension-cache-cloudflare": "2.0.0-next.11",
189
- "@baeta/extension-cache-keyv": "2.0.0-next.11",
190
- "@baeta/extension-cache-redis": "2.0.0-next.11",
191
- "@baeta/extension-cache-upstash": "2.0.0-next.11",
192
- "@baeta/extension-complexity": "2.0.0-next.11",
193
- "@baeta/generator": "2.0.0-next.4",
194
- "@baeta/generator-sdk": "2.0.0-next.4",
195
- "@baeta/plugin": "2.0.0-next.3",
196
- "@baeta/plugin-cloudflare": "2.0.0-next.11",
197
- "@baeta/plugin-directives": "2.0.0-next.11",
198
- "@baeta/plugin-exec": "2.0.0-next.11",
199
- "@baeta/plugin-gitignore": "2.0.0-next.11",
200
- "@baeta/plugin-graphql": "2.0.0-next.11",
201
- "@baeta/plugin-pagination": "2.0.0-next.11",
202
- "@baeta/plugin-prisma": "2.0.0-next.11",
203
- "@baeta/subscriptions-cloudflare": "0.2.0-next.2",
204
- "@baeta/subscriptions-pubsub": "2.0.0-next.11",
205
- "@baeta/util-encoding": "2.0.0-next.3",
206
- "@baeta/util-env": "2.0.0-next.3",
207
- "@baeta/util-log": "2.0.0-next.3",
208
- "@baeta/util-path": "2.0.0-next.3"
209
- };
210
-
211
186
  //#endregion
212
187
  //#region templates/shared.ts
213
- function makeSharedTemplate(appName, runtime, packageJson) {
188
+ function makeSharedTemplate(appName, runtime, packageJson, versions) {
214
189
  return [
215
- makePackageJson(appName, runtime, packageJson),
190
+ makePackageJson(appName, runtime, packageJson, versions),
216
191
  {
217
192
  relativePath: "./tsconfig.json",
218
193
  content: JSON.stringify({
@@ -531,10 +506,9 @@ dist
531
506
  }
532
507
  ];
533
508
  }
534
- function makePackageJson(appName, runtime, packageJson) {
509
+ function makePackageJson(appName, runtime, packageJson, versions) {
535
510
  const meta = structuredClone(packageJson);
536
- for (const [dep, version$2] of Object.entries(versions_default)) if (dep in meta.dependencies) meta.dependencies[dep] = version$2;
537
- else if (dep in packageJson.devDependencies) meta.devDependencies[dep] = version$2;
511
+ for (const field of ["dependencies", "devDependencies"]) for (const [dep, version] of Object.entries(versions[field] ?? {})) meta[field][dep] = version;
538
512
  if (runtime === "node") {
539
513
  meta.devDependencies["@types/bun"] = void 0;
540
514
  meta.devDependencies["@types/deno"] = void 0;
@@ -555,12 +529,11 @@ function makePackageJson(appName, runtime, packageJson) {
555
529
  content: JSON.stringify(meta, null, 2)
556
530
  };
557
531
  }
558
-
559
532
  //#endregion
560
533
  //#region templates/apollo.ts
561
534
  async function makeApolloTemplate(appName, runtime) {
562
535
  return [
563
- ...makeSharedTemplate(appName, runtime, package_default$1),
536
+ ...makeSharedTemplate(appName, runtime, package_default$1, versions_apollo_default),
564
537
  {
565
538
  relativePath: "./src/types/context.ts",
566
539
  content: `export type Context = {
@@ -593,7 +566,6 @@ console.log(\`🚀 Server ready at: \${url}\`);
593
566
  }
594
567
  ];
595
568
  }
596
-
597
569
  //#endregion
598
570
  //#region meta/yoga/package.json
599
571
  var package_default = {
@@ -609,23 +581,39 @@ var package_default = {
609
581
  "@baeta/core": "workspace:^",
610
582
  "@baeta/errors": "workspace:^",
611
583
  "@baeta/extension-complexity": "workspace:^",
612
- "graphql": "^16.12.0",
613
- "graphql-yoga": "^5.17.0"
584
+ "graphql": "catalog:dev",
585
+ "graphql-yoga": "catalog:dev"
614
586
  },
615
587
  devDependencies: {
616
588
  "@baeta/cli": "workspace:^",
617
- "@types/bun": "^1.3.3",
589
+ "@types/bun": "^1.3.11",
618
590
  "@types/deno": "^2.5.0",
619
- "@types/node": "^22.19.1",
620
- "typescript": "^5.9.3"
591
+ "@types/node": "catalog:dev",
592
+ "typescript": "catalog:dev"
621
593
  }
622
594
  };
623
-
595
+ //#endregion
596
+ //#region versions.yoga.json
597
+ var versions_yoga_default = {
598
+ dependencies: {
599
+ "@baeta/core": "^2.0.0-next.12",
600
+ "@baeta/errors": "^2.0.0-next.12",
601
+ "@baeta/extension-complexity": "^2.0.0-next.12",
602
+ "graphql": "^16.6.0",
603
+ "graphql-yoga": "^5.20.0"
604
+ },
605
+ devDependencies: {
606
+ "@baeta/cli": "^2.0.0-next.12",
607
+ "@types/node": "^22.19.13",
608
+ "typescript": "^5.9.3"
609
+ },
610
+ peerDependencies: {}
611
+ };
624
612
  //#endregion
625
613
  //#region templates/yoga.ts
626
614
  async function makeYogaTemplate(appName, runtime) {
627
615
  return [
628
- ...makeSharedTemplate(appName, runtime, package_default),
616
+ ...makeSharedTemplate(appName, runtime, package_default, versions_yoga_default),
629
617
  ...makeRuntimeFiles(runtime),
630
618
  {
631
619
  relativePath: "./src/types/context.ts",
@@ -733,7 +721,6 @@ server.listen(4000, () => {
733
721
  `
734
722
  }];
735
723
  }
736
-
737
724
  //#endregion
738
725
  //#region lib/templates.ts
739
726
  function createTemplateChoices() {
@@ -774,7 +761,6 @@ async function copyTemplate(appName, runtime, template, dest) {
774
761
  });
775
762
  await Promise.all(promises);
776
763
  }
777
-
778
764
  //#endregion
779
765
  //#region lib/handler.ts
780
766
  async function handler(args) {
@@ -826,7 +812,7 @@ We recommend that you begin by typing:
826
812
  code=${start}
827
813
  `;
828
814
  }
829
-
830
815
  //#endregion
831
816
  export { getInstallCommand as a, defaultJavaScriptRuntime as c, packageManagers as d, runtimes as f, getRuntime as i, defaultPackageManager as l, copyTemplate as n, getPackageManager as o, templates as p, getTemplate as r, getAppName as s, handler as t, lockfileNames as u };
832
- //# sourceMappingURL=handler-gi3zJbO5.js.map
817
+
818
+ //# sourceMappingURL=handler-CrK2lbPA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-CrK2lbPA.js","names":["tsconfig","tsconfig.compilerOptions","apolloPackageJson","versions","yogaPackageJson","versions"],"sources":["../lib/constants.ts","../lib/app-name.ts","../lib/package-manager.ts","../lib/runtime.ts","../meta/apollo/package.json","../versions.apollo.json","../../../tools/tsconfig/tsconfig.json","../templates/shared.ts","../templates/apollo.ts","../meta/yoga/package.json","../versions.yoga.json","../templates/yoga.ts","../lib/templates.ts","../lib/handler.ts"],"sourcesContent":["export const defaultPackageManager = 'npm';\n\nexport const lockfileNames = {\n\tnpm: 'package-lock.json',\n\tyarn: 'yarn.lock',\n\tpnpm: 'pnpm-lock.yaml',\n\tbun: 'bun.lockb',\n};\n\nexport const packageManagers = Object.keys(lockfileNames) as PackageManager[];\n\nexport type PackageManager = keyof typeof lockfileNames;\n\nexport const runtimes = ['node', 'deno', 'bun'] as const;\n\nexport type JavaScriptRuntime = (typeof runtimes)[number];\n\nexport const defaultJavaScriptRuntime = 'node';\n\nexport const templates = ['yoga', 'apollo'] as const;\nexport type Template = (typeof templates)[number];\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts from 'prompts';\n\nexport async function getAppName(reqName: string | undefined, rootDir: string): Promise<string> {\n\tasync function validateAppName(appName: string) {\n\t\tif (!appName) {\n\t\t\treturn 'An app name is required.';\n\t\t}\n\t\tconst dest = path.resolve(rootDir, appName);\n\t\tif (await fs.pathExists(dest)) {\n\t\t\treturn logger.interpolate`Directory already exists at path=${dest}!`;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (reqName) {\n\t\tconst res = await validateAppName(reqName);\n\t\tif (typeof res === 'string') {\n\t\t\tthrow new TypeError(res);\n\t\t}\n\t\treturn reqName;\n\t}\n\n\treturn prompts(\n\t\t{\n\t\t\ttype: 'text',\n\t\t\tname: 'appName',\n\t\t\tmessage: 'What should we name this app?',\n\t\t\tinitial: 'baeta-app',\n\t\t\tvalidate: validateAppName,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.error('An app name is required.');\n\t\t\t\tprocess.exit(1);\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { appName: string }).appName);\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts from 'prompts';\nimport shell from 'shelljs';\nimport type { CliOptions } from './cli-options.ts';\nimport {\n\tdefaultPackageManager,\n\tlockfileNames,\n\ttype PackageManager,\n\tpackageManagers,\n} from './constants.ts';\n\nasync function findPackageManagerFromLockFile(\n\trootDir: string,\n): Promise<PackageManager | undefined> {\n\tfor (const packageManager of packageManagers) {\n\t\tconst lockFilePath = path.join(rootDir, lockfileNames[packageManager]);\n\t\tif (await fs.pathExists(lockFilePath)) {\n\t\t\treturn packageManager;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction findPackageManagerFromUserAgent(): PackageManager | undefined {\n\treturn packageManagers.find((packageManager) =>\n\t\tprocess.env.npm_config_user_agent?.startsWith(packageManager),\n\t);\n}\n\nasync function askForPackageManagerChoice(): Promise<PackageManager> {\n\tconst hasYarn = shell.exec('yarn --version', { silent: true }).code === 0;\n\tconst hasPnpm = shell.exec('pnpm --version', { silent: true }).code === 0;\n\tconst hasBun = shell.exec('bun --version', { silent: true }).code === 0;\n\n\tif (!hasYarn && !hasPnpm && !hasBun) {\n\t\treturn 'npm';\n\t}\n\tconst choices = ['npm', hasYarn && 'yarn', hasPnpm && 'pnpm', hasBun && 'bun']\n\t\t.filter((p) => p !== false)\n\t\t.map((p) => ({ title: p, value: p }));\n\n\tconst manager = await prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'packageManager',\n\t\t\tmessage: 'Select a package manager...',\n\t\t\tchoices,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.info`Falling back to name=${defaultPackageManager}`;\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { packageManager?: PackageManager }).packageManager);\n\n\treturn manager ?? defaultPackageManager;\n}\n\nexport async function getPackageManager(\n\tdest: string,\n\t{ packageManager, skipInstall }: CliOptions,\n): Promise<PackageManager> {\n\tif (packageManager && !packageManagers.includes(packageManager)) {\n\t\tthrow new Error(\n\t\t\t`Invalid package manager choice ${packageManager}. Must be one of ${packageManagers.join(\n\t\t\t\t', ',\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tconst fromLockfile = await findPackageManagerFromLockFile(dest);\n\n\tif (fromLockfile) {\n\t\treturn fromLockfile;\n\t}\n\n\tif (packageManager) {\n\t\treturn packageManager;\n\t}\n\n\tconst fromLockfileInCwd = await findPackageManagerFromLockFile('.');\n\n\tif (fromLockfileInCwd) {\n\t\treturn fromLockfileInCwd;\n\t}\n\n\tconst fromUserAgent = findPackageManagerFromUserAgent();\n\n\tif (fromUserAgent) {\n\t\treturn fromUserAgent;\n\t}\n\n\tif (skipInstall) {\n\t\treturn defaultPackageManager;\n\t}\n\n\treturn askForPackageManagerChoice();\n}\n\nexport function getInstallCommand(pkgManager: PackageManager): string {\n\tif (pkgManager === 'yarn') {\n\t\treturn 'yarn';\n\t}\n\tif (pkgManager === 'bun') {\n\t\treturn 'bun install';\n\t}\n\treturn `${pkgManager} install --color always`;\n}\n","import { logger } from '@docusaurus/logger';\nimport prompts from 'prompts';\nimport shell from 'shelljs';\nimport { defaultJavaScriptRuntime, type JavaScriptRuntime } from './constants.ts';\n\nexport async function getRuntime(): Promise<JavaScriptRuntime> {\n\tconst hasBun = shell.exec('bun --version', { silent: true }).code === 0;\n\tconst hasDeno = shell.exec('deno --version', { silent: true }).code === 0;\n\n\tif (!hasDeno && !hasBun) {\n\t\treturn 'node';\n\t}\n\tconst choices = ['node', hasBun && 'bun', hasDeno && 'deno']\n\t\t.filter((p) => p !== false)\n\t\t.map((p) => ({ title: p, value: p }));\n\n\tconst runtime = await prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'runtime',\n\t\t\tmessage: 'Select a runtime...',\n\t\t\tchoices,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.info`Falling back to name=${defaultJavaScriptRuntime}`;\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { runtime?: JavaScriptRuntime }).runtime);\n\n\treturn runtime ?? defaultJavaScriptRuntime;\n}\n","","","","import tsconfig from '../../../tools/tsconfig/tsconfig.json';\nimport type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\n\nexport type PackageJson = {\n\tname: string;\n\tscripts: Record<string, string | undefined>;\n\tdependencies: Record<string, string | undefined>;\n\tdevDependencies: Record<string, string | undefined>;\n};\n\nexport type ResolvedPackageVersions = {\n\tdependencies: Record<string, string | undefined>;\n\tdevDependencies: Record<string, string | undefined>;\n\tpeerDependencies: Record<string, string | undefined>;\n};\n\nexport function makeSharedTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\tpackageJson: PackageJson,\n\tversions: ResolvedPackageVersions,\n): TemplateFile[] {\n\treturn [\n\t\tmakePackageJson(appName, runtime, packageJson, versions),\n\t\t{\n\t\t\trelativePath: './tsconfig.json',\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\t...tsconfig,\n\t\t\t\t\tcompilerOptions: {\n\t\t\t\t\t\t...tsconfig.compilerOptions,\n\t\t\t\t\t\trootDir: 'src',\n\t\t\t\t\t\toutDir: 'dist',\n\t\t\t\t\t\tnoEmit: true,\n\t\t\t\t\t\temitDeclarationOnly: false,\n\t\t\t\t\t},\n\t\t\t\t\texclude: ['baeta.ts'],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/extensions.ts',\n\t\t\tcontent: `import { createExtensions } from '@baeta/core';\nimport { complexityExtension } from '@baeta/extension-complexity';\nimport type { Context } from '../types/context.ts';\n\nconst complexity = complexityExtension<Context>({\n\tdefaultComplexity: 1,\n\tdefaultListMultiplier: 10,\n\tasync limit(ctx) {\n\t\treturn {\n\t\t\tdepth: 10,\n\t\t\tbreadth: 50,\n\t\t\tcomplexity: 1000,\n\t\t};\n\t},\n});\n\nexport default createExtensions({\n\tcomplexityExtension: complexity\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user/user.gql',\n\t\t\tcontent: `type User {\n\tid: ID!\n\temail: String!\n\tlastName: String!\n\tprofile: String\n\tgivenName: String\n}\n\ninput UserWhereUniqueInput {\n\tid: ID!\n}\n\ntype Query {\n\tuser(where: UserWhereUniqueInput!): User\n\tusers: [User!]\n}\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user/index.ts',\n\t\t\tcontent: `import { UserModule } from './typedef.ts';\n\nconst { Query, User } = UserModule;\n\nconst userQuery = Query.user\n\t.$use(async (next, { args }) => {\n\t\tconst result = await next();\n\t\tconsole.log('Got user:', result, 'for args:', args);\n\t\treturn result;\n\t})\n\t.resolve(({ args }) => {\n\t\treturn {\n\t\t\tid: args.where.id,\n\t\t\temail: 'jon.doe@baeta.io',\n\t\t\tlastName: 'Doe',\n\t\t\tgivenName: null,\n\t\t\tprofile: null,\n\t\t};\n\t});\n\nconst usersQuery = Query.users.resolve(() => {\n\tconst users = Array.from({ length: 10 }).map((_, i) => ({\n\t\tid: i.toString(),\n\t\temail: \\`jon.doe\\${i}@baeta.io\\`,\n\t\tlastName: \\`Doe \\${i}\\`,\n\t\tgivenName: null,\n\t\tprofile: null,\n\t}));\n\treturn users;\n});\n\nexport default UserModule.$schema({\n\tUser: User.$fields({\n\t\tid: User.id.key('id'),\n\t\temail: User.email.key('email'),\n\t\tlastName: User.lastName.key('lastName'),\n\t\tgivenName: User.givenName.key('givenName').undefinedAsNull(),\n\t\tprofile: User.profile.key('profile').undefinedAsNull(),\n\t}),\n\tQuery: Query.$fields({\n\t\tuser: userQuery,\n\t\tusers: usersQuery,\n\t}),\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user-photos/user-photos.gql',\n\t\t\tcontent: `type UserPhoto {\n\tid: ID!\n\tuserId: ID!\n\turl: String!\n}\n\nextend type User {\n\tphotos: [UserPhoto!]\n}\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user-photos/index.ts',\n\t\t\tcontent: `import { UserPhotosModule } from './typedef.ts';\n\nconst { User, UserPhoto } = UserPhotosModule;\n\nexport default UserPhotosModule.$schema({\n\tUser: User.$fields({\n\t\tphotos: User.photos.resolve(({ source }) => {\n\t\t\treturn Array.from({ length: 10 }).map((_, i) => ({\n\t\t\t\tid: \\`u\\${source.id}_p\\${i}\\`,\n\t\t\t\tuserId: source.id,\n\t\t\t\turl: \\`https://baeta.io/user/\\${source.id}/photo/\\${i}.png\\`,\n\t\t\t}));\n\t\t}),\n\t}),\n\tUserPhoto: UserPhoto.$fields({\n\t\tid: UserPhoto.id.key('id'),\n\t\turl: UserPhoto.url.key('url'),\n\t\tuserId: UserPhoto.userId.key('userId'),\n\t}),\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/types.ts',\n\t\t\tcontent: `import type { GraphQLResolveInfo } from 'graphql';\nimport type { BaseObjectTypes, BaseScalars } from '../__generated__/utility.ts';\nimport type { Context } from '../types/context.ts';\n\nexport interface Scalars extends BaseScalars {}\n\nexport interface ObjectTypes extends BaseObjectTypes {\n\tUser: {\n\t\tid: string;\n\t\temail: string;\n\t\tlastName: string;\n\t\tgivenName?: string | null;\n\t\tprofile?: string | null;\n\t};\n}\n\nexport type Ctx = Context;\n\nexport type Info = GraphQLResolveInfo;\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './baeta.ts',\n\t\t\tcontent: `import { defineConfig } from '@baeta/cli';\n\nexport default defineConfig({\n\tgraphql: {\n\t\tschemas: ['src/**/*.gql'],\n\t},\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './.gitignore',\n\t\t\tcontent: `# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional stylelint cache\n.stylelintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variable files\n.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# vuepress v2.x temp and cache directory\n.temp\n.cache\n\n# vitepress build output\n**/.vitepress/dist\n\n# vitepress cache directory\n**/.vitepress/cache\n\n# Docusaurus cache and generated files\n.docusaurus\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*\n`,\n\t\t},\n\t];\n}\n\nfunction makePackageJson(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\tpackageJson: {\n\t\tname: string;\n\t\tscripts: Record<string, string | undefined>;\n\t\tdependencies: Record<string, string | undefined>;\n\t\tdevDependencies: Record<string, string | undefined>;\n\t},\n\tversions: ResolvedPackageVersions,\n) {\n\tconst meta = structuredClone(packageJson);\n\tconst fields = ['dependencies', 'devDependencies'] as const;\n\tfor (const field of fields) {\n\t\tfor (const [dep, version] of Object.entries(versions[field] ?? {})) {\n\t\t\tmeta[field][dep] = version;\n\t\t}\n\t}\n\n\tif (runtime === 'node') {\n\t\tmeta.devDependencies['@types/bun'] = undefined;\n\t\tmeta.devDependencies['@types/deno'] = undefined;\n\t}\n\n\tif (runtime === 'bun') {\n\t\tmeta.scripts.start = `baeta generate --watch --run='bun --watch --inspect src/app.ts'`;\n\t\tmeta.devDependencies['@types/node'] = undefined;\n\t\tmeta.devDependencies['@types/deno'] = undefined;\n\t}\n\n\tif (runtime === 'deno') {\n\t\tmeta.scripts.start = `baeta generate --watch --run='deno --watch --allow-env --allow-read --allow-net src/app.ts'`;\n\t\tmeta.devDependencies['@types/node'] = undefined;\n\t\tmeta.devDependencies['@types/bun'] = undefined;\n\t}\n\n\tmeta.name = appName;\n\n\treturn {\n\t\trelativePath: './package.json',\n\t\tcontent: JSON.stringify(meta, null, 2),\n\t};\n}\n","import type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\nimport apolloPackageJson from '../meta/apollo/package.json';\nimport versions from '../versions.apollo.json';\nimport { makeSharedTemplate } from './shared.ts';\n\nexport async function makeApolloTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n): Promise<TemplateFile[]> {\n\treturn [\n\t\t...makeSharedTemplate(appName, runtime, apolloPackageJson, versions),\n\t\t{\n\t\t\trelativePath: './src/types/context.ts',\n\t\t\tcontent: `export type Context = {\n\tuserId?: string;\n};\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { ApolloServer } from '@apollo/server';\nimport { startStandaloneServer } from '@apollo/server/standalone';\nimport { createApplication } from '@baeta/core';\nimport modules from './modules/index.ts';\nimport type { Context } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nconst server = new ApolloServer<Context>({\n\tschema: baeta.schema,\n});\n\nconst { url } = await startStandaloneServer(server, {\n\tlisten: { port: 4000 },\n});\n\nconsole.log(\\`🚀 Server ready at: \\${url}\\`);\n`,\n\t\t},\n\t];\n}\n","","","import type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\nimport yogaPackageJson from '../meta/yoga/package.json';\nimport versions from '../versions.yoga.json';\nimport { makeSharedTemplate } from './shared.ts';\n\nexport async function makeYogaTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n): Promise<TemplateFile[]> {\n\treturn [\n\t\t...makeSharedTemplate(appName, runtime, yogaPackageJson, versions),\n\t\t...makeRuntimeFiles(runtime),\n\t\t{\n\t\t\trelativePath: './src/types/context.ts',\n\t\t\tcontent: `export type Context = {\n\tappVersion: string;\n};\n\nexport type ServerContext = {};\n`,\n\t\t},\n\t];\n}\n\nfunction makeRuntimeFiles(runtime: JavaScriptRuntime): TemplateFile[] {\n\tswitch (runtime) {\n\t\tcase 'bun':\n\t\t\treturn makeBunFiles();\n\t\tcase 'deno':\n\t\t\treturn makeDenoFiles();\n\t\tcase 'node':\n\t\t\treturn makeNodeFiles();\n\t\tdefault:\n\t\t\treturn [] satisfies never[];\n\t}\n}\n\nfunction makeBunFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nBun.serve({\n\tfetch: yoga.fetch,\n\tport: 4000,\n});\n\nconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n`,\n\t\t},\n\t];\n}\n\nfunction makeDenoFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nDeno.serve(\n\t{\n\t\tport: 4000,\n\t\tonListen() {\n\t\t\tconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n\t\t},\n\t},\n\tyoga.fetch,\n);\n`,\n\t\t},\n\t];\n}\n\nfunction makeNodeFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createServer } from 'node:http';\nimport { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nconst server = createServer(yoga);\n\nserver.listen(4000, () => {\n\tconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n});\n`,\n\t\t},\n\t];\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts, { type Choice } from 'prompts';\nimport { makeApolloTemplate } from '../templates/apollo.ts';\nimport { makeYogaTemplate } from '../templates/yoga.ts';\nimport { type JavaScriptRuntime, type Template, templates } from './constants.ts';\n\nfunction createTemplateChoices(): Choice[] {\n\treturn templates.map((template) => ({ title: template, value: template }));\n}\n\nasync function askTemplateChoice() {\n\treturn prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'template',\n\t\t\tmessage: 'Select a template below...',\n\t\t\tchoices: createTemplateChoices(),\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.error('A choice is required.');\n\t\t\t\tprocess.exit(1);\n\t\t\t},\n\t\t},\n\t).then((result) => {\n\t\treturn (result as { template: Template }).template;\n\t});\n}\n\nexport async function getTemplate(reqTemplate: string | undefined) {\n\tconst userProvided = reqTemplate ? templates.find((t) => t === reqTemplate) : null;\n\tconst template = userProvided ?? (await askTemplateChoice());\n\n\tif (!template) {\n\t\tthrow new Error('Template not found');\n\t}\n\n\treturn template;\n}\n\nfunction getTemplateFiles(template: Template, appName: string, runtime: JavaScriptRuntime) {\n\tswitch (template) {\n\t\tcase 'yoga':\n\t\t\treturn makeYogaTemplate(appName, runtime);\n\t\tcase 'apollo':\n\t\t\treturn makeApolloTemplate(appName, runtime);\n\t\tdefault:\n\t\t\treturn [] satisfies never[];\n\t}\n}\n\nexport async function copyTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\ttemplate: Template,\n\tdest: string,\n) {\n\tconst files = await getTemplateFiles(template, appName, runtime);\n\n\tconst promises = files.map((file) => {\n\t\tconst filePath = path.join(dest, file.relativePath);\n\t\treturn fs.ensureDir(path.dirname(filePath)).then(() => fs.writeFile(filePath, file.content));\n\t});\n\n\tawait Promise.all(promises);\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport shell from 'shelljs';\nimport supportsColor from 'supports-color';\nimport { getAppName } from './app-name.ts';\nimport type { PackageManager } from './constants.ts';\nimport { getInstallCommand, getPackageManager } from './package-manager.ts';\nimport { getRuntime } from './runtime.ts';\nimport { copyTemplate, getTemplate } from './templates.ts';\n\nexport interface Args {\n\tpackageManager?: PackageManager;\n\tskipInstall?: boolean;\n\tappName?: string;\n\ttemplate?: string;\n\trootDir: string;\n}\n\nexport async function handler(args: Args) {\n\tconst appName = await getAppName(args.appName, args.rootDir);\n\tconst dest = path.resolve(args.rootDir, appName);\n\n\tconst template = await getTemplate(args.template);\n\n\tconst runtime = await getRuntime();\n\n\tlogger.info('Creating new Baeta project...');\n\n\ttry {\n\t\tawait copyTemplate(appName, runtime, template, dest);\n\t} catch (err) {\n\t\tlogger.error`Copying Baeta template name=${template} failed!`;\n\t\tthrow err;\n\t}\n\n\tconst pkgManager = await getPackageManager(dest, args);\n\n\tconst useNpm = pkgManager === 'npm';\n\tconst useBun = pkgManager === 'bun';\n\tconst useRunCommand = useNpm || useBun;\n\tconst runCommand = useRunCommand ? 'run ' : '';\n\n\tconst start = `${pkgManager} start`;\n\tconst build = `${pkgManager} ${runCommand}build`;\n\tconst cd = `cd ${dest}`;\n\tconst install = `${pkgManager} install`;\n\n\tif (!args.skipInstall) {\n\t\tshell.cd(dest);\n\t\tlogger.info`Installing dependencies with name=${pkgManager}...`;\n\t\tconst result = shell.exec(getInstallCommand(pkgManager), {\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...(supportsColor.stdout ? { FORCE_COLOR: '1' } : {}),\n\t\t\t},\n\t\t});\n\n\t\tif (result.code !== 0) {\n\t\t\tconsole.error('Dependency installation failed.');\n\t\t\tlogger.error('Dependency installation failed.');\n\t\t\tlogger.info`The app directory has already been created, and you can retry by typing:\n\ncode=${cd}\ncode=${install}`;\n\n\t\t\tprocess.exit(0);\n\t\t}\n\t}\n\n\tlogger.success`Created name=${dest}.`;\n\n\tlogger.info`Inside that directory, you can run several commands:\n\n code=${start}\n Starts the development server.\n\n code=${build}\n Generates the Baeta application.\n\nWe recommend that you begin by typing:\n\n code=${cd}\n code=${start}\n`;\n}\n"],"mappings":";;;;;;;AAAA,MAAa,wBAAwB;AAErC,MAAa,gBAAgB;CAC5B,KAAK;CACL,MAAM;CACN,MAAM;CACN,KAAK;CACL;AAED,MAAa,kBAAkB,OAA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AQ;CAEhD,MAAM,WAAW,MAAM,YAAY,KAAK,SAAS;CAEjD,MAAM,UAAU,MAAM,YAAY;AAElC,QAAO,KAAK,gCAAgC;AAE5C,KAAI;AACH,QAAM,aAAa,SAAS,SAAS,UAAU,KAAK;UAC5C,KAAK;AACb,SAAO,KAAK,+BAA+B,SAAS;AACpD,QAAM;;CAGP,MAAM,aAAa,MAAM,kBAAkB,MAAM,KAAK;CAKtD,MAAM,aAHS,eAAe,SACf,eAAe,QAEK,SAAS;CAE5C,MAAM,QAAQ,GAAG,WAAW;CAC5B,MAAM,QAAQ,GAAG,WAAW,GAAG,WAAW;CAC1C,MAAM,KAAK,MAAM;CACjB,MAAM,UAAU,GAAG,WAAW;AAE9B,KAAI,CAAC,KAAK,aAAa;AACtB,QAAM,GAAG,KAAK;AACd,SAAO,IAAI,qCAAqC,WAAW;AAQ3D,MAPe,MAAM,KAAK,kBAAkB,WAAW,EAAE,EACxD,KAAK;GACJ,GAAG,QAAQ;GACX,GAAI,cAAc,SAAS,EAAE,aAAa,KAAK,GAAG,EAAE;GACpD,EACD,CAAC,CAES,SAAS,GAAG;AACtB,WAAQ,MAAM,kCAAkC;AAChD,UAAO,MAAM,kCAAkC;AAC/C,UAAO,IAAI;;OAEP,GAAG;OACH;AAEJ,WAAQ,KAAK,EAAE;;;AAIjB,QAAO,OAAO,gBAAgB,KAAK;AAEnC,QAAO,IAAI;;SAEH,MAAM;;;SAGN,MAAM;;;;;SAKN,GAAG;SACH,MAAM"}
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
- import { a as getInstallCommand, c as defaultJavaScriptRuntime, d as packageManagers, f as runtimes, i as getRuntime, l as defaultPackageManager, n as copyTemplate, o as getPackageManager, p as templates, r as getTemplate, s as getAppName, t as handler, u as lockfileNames } from "./handler-gi3zJbO5.js";
2
-
3
- export { copyTemplate, defaultJavaScriptRuntime, defaultPackageManager, getAppName, getInstallCommand, getPackageManager, getRuntime, getTemplate, handler, lockfileNames, packageManagers, runtimes, templates };
1
+ import { a as getInstallCommand, c as defaultJavaScriptRuntime, d as packageManagers, f as runtimes, i as getRuntime, l as defaultPackageManager, n as copyTemplate, o as getPackageManager, p as templates, r as getTemplate, s as getAppName, t as handler, u as lockfileNames } from "./handler-CrK2lbPA.js";
2
+ export { copyTemplate, defaultJavaScriptRuntime, defaultPackageManager, getAppName, getInstallCommand, getPackageManager, getRuntime, getTemplate, handler, lockfileNames, packageManagers, runtimes, templates };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-baeta",
3
- "version": "2.0.0-next.11",
3
+ "version": "2.0.0-next.12",
4
4
  "keywords": [
5
5
  "baeta",
6
6
  "graphql",
@@ -35,17 +35,19 @@
35
35
  "bin": "dist/cli.js",
36
36
  "files": [
37
37
  "dist",
38
- "templates",
39
38
  "package.json"
40
39
  ],
41
40
  "scripts": {
42
- "prebuild": "node --no-warnings --experimental-transform-types ./scripts/version-manifest.ts",
41
+ "prebuild": "yarn write:apollo:versions && yarn write:yoga:versions",
43
42
  "build": "yarn prebuild && builder build",
43
+ "check:deps": "builder check-deps",
44
44
  "prepack": "builder prepare",
45
- "postpack": "builder prepare --clean",
45
+ "postpack": "builder prepare --restore",
46
46
  "test": "builder test",
47
47
  "test:circular": "builder test-circular",
48
- "types": "yarn prebuild && tsc --noEmit"
48
+ "types": "yarn prebuild && tsc --noEmit",
49
+ "write:apollo:versions": "builder print-resolved-versions ./meta/apollo/package.json -o versions.apollo.json",
50
+ "write:yoga:versions": "builder print-resolved-versions ./meta/yoga/package.json -o versions.yoga.json"
49
51
  },
50
52
  "ava": {
51
53
  "extensions": {
@@ -54,9 +56,9 @@
54
56
  },
55
57
  "dependencies": {
56
58
  "@docusaurus/logger": "^3.9.2",
57
- "fs-extra": "^11.3.2",
59
+ "fs-extra": "^11.3.4",
58
60
  "prompts": "^2.4.2",
59
- "semver": "^7.7.3",
61
+ "semver": "^7.7.4",
60
62
  "shelljs": "^0.10.0",
61
63
  "supports-color": "^10.2.2",
62
64
  "yargs": "^18.0.0"
@@ -66,10 +68,10 @@
66
68
  "@baeta/testing": "^0.0.0",
67
69
  "@baeta/tsconfig": "^0.0.0",
68
70
  "@types/fs-extra": "^11.0.4",
69
- "@types/node": "^22.19.1",
71
+ "@types/node": "^22.19.13",
70
72
  "@types/prompts": "^2.4.9",
71
73
  "@types/semver": "^7.7.1",
72
- "@types/shelljs": "^0.8.17",
74
+ "@types/shelljs": "^0.10.0",
73
75
  "@types/yargs": "^17.0.35",
74
76
  "typescript": "^5.9.3"
75
77
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler-gi3zJbO5.js","names":["tsconfig","tsconfig.compilerOptions","version","dependenciesVersions","apolloPackageJson","yogaPackageJson"],"sources":["../lib/constants.ts","../lib/app-name.ts","../lib/package-manager.ts","../lib/runtime.ts","../meta/apollo/package.json","../../../tools/tsconfig/tsconfig.json","../versions.json","../templates/shared.ts","../templates/apollo.ts","../meta/yoga/package.json","../templates/yoga.ts","../lib/templates.ts","../lib/handler.ts"],"sourcesContent":["export const defaultPackageManager = 'npm';\n\nexport const lockfileNames = {\n\tnpm: 'package-lock.json',\n\tyarn: 'yarn.lock',\n\tpnpm: 'pnpm-lock.yaml',\n\tbun: 'bun.lockb',\n};\n\nexport const packageManagers = Object.keys(lockfileNames) as PackageManager[];\n\nexport type PackageManager = keyof typeof lockfileNames;\n\nexport const runtimes = ['node', 'deno', 'bun'] as const;\n\nexport type JavaScriptRuntime = (typeof runtimes)[number];\n\nexport const defaultJavaScriptRuntime = 'node';\n\nexport const templates = ['yoga', 'apollo'] as const;\nexport type Template = (typeof templates)[number];\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts from 'prompts';\n\nexport async function getAppName(reqName: string | undefined, rootDir: string): Promise<string> {\n\tasync function validateAppName(appName: string) {\n\t\tif (!appName) {\n\t\t\treturn 'An app name is required.';\n\t\t}\n\t\tconst dest = path.resolve(rootDir, appName);\n\t\tif (await fs.pathExists(dest)) {\n\t\t\treturn logger.interpolate`Directory already exists at path=${dest}!`;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (reqName) {\n\t\tconst res = await validateAppName(reqName);\n\t\tif (typeof res === 'string') {\n\t\t\tthrow new TypeError(res);\n\t\t}\n\t\treturn reqName;\n\t}\n\n\treturn prompts(\n\t\t{\n\t\t\ttype: 'text',\n\t\t\tname: 'appName',\n\t\t\tmessage: 'What should we name this app?',\n\t\t\tinitial: 'baeta-app',\n\t\t\tvalidate: validateAppName,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.error('An app name is required.');\n\t\t\t\tprocess.exit(1);\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { appName: string }).appName);\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts from 'prompts';\nimport shell from 'shelljs';\nimport type { CliOptions } from './cli-options.ts';\nimport {\n\tdefaultPackageManager,\n\tlockfileNames,\n\ttype PackageManager,\n\tpackageManagers,\n} from './constants.ts';\n\nasync function findPackageManagerFromLockFile(\n\trootDir: string,\n): Promise<PackageManager | undefined> {\n\tfor (const packageManager of packageManagers) {\n\t\tconst lockFilePath = path.join(rootDir, lockfileNames[packageManager]);\n\t\tif (await fs.pathExists(lockFilePath)) {\n\t\t\treturn packageManager;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction findPackageManagerFromUserAgent(): PackageManager | undefined {\n\treturn packageManagers.find((packageManager) =>\n\t\tprocess.env.npm_config_user_agent?.startsWith(packageManager),\n\t);\n}\n\nasync function askForPackageManagerChoice(): Promise<PackageManager> {\n\tconst hasYarn = shell.exec('yarn --version', { silent: true }).code === 0;\n\tconst hasPnpm = shell.exec('pnpm --version', { silent: true }).code === 0;\n\tconst hasBun = shell.exec('bun --version', { silent: true }).code === 0;\n\n\tif (!hasYarn && !hasPnpm && !hasBun) {\n\t\treturn 'npm';\n\t}\n\tconst choices = ['npm', hasYarn && 'yarn', hasPnpm && 'pnpm', hasBun && 'bun']\n\t\t.filter((p) => p !== false)\n\t\t.map((p) => ({ title: p, value: p }));\n\n\tconst manager = await prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'packageManager',\n\t\t\tmessage: 'Select a package manager...',\n\t\t\tchoices,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.info`Falling back to name=${defaultPackageManager}`;\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { packageManager?: PackageManager }).packageManager);\n\n\treturn manager ?? defaultPackageManager;\n}\n\nexport async function getPackageManager(\n\tdest: string,\n\t{ packageManager, skipInstall }: CliOptions,\n): Promise<PackageManager> {\n\tif (packageManager && !packageManagers.includes(packageManager)) {\n\t\tthrow new Error(\n\t\t\t`Invalid package manager choice ${packageManager}. Must be one of ${packageManagers.join(\n\t\t\t\t', ',\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tconst fromLockfile = await findPackageManagerFromLockFile(dest);\n\n\tif (fromLockfile) {\n\t\treturn fromLockfile;\n\t}\n\n\tif (packageManager) {\n\t\treturn packageManager;\n\t}\n\n\tconst fromLockfileInCwd = await findPackageManagerFromLockFile('.');\n\n\tif (fromLockfileInCwd) {\n\t\treturn fromLockfileInCwd;\n\t}\n\n\tconst fromUserAgent = findPackageManagerFromUserAgent();\n\n\tif (fromUserAgent) {\n\t\treturn fromUserAgent;\n\t}\n\n\tif (skipInstall) {\n\t\treturn defaultPackageManager;\n\t}\n\n\treturn askForPackageManagerChoice();\n}\n\nexport function getInstallCommand(pkgManager: PackageManager): string {\n\tif (pkgManager === 'yarn') {\n\t\treturn 'yarn';\n\t}\n\tif (pkgManager === 'bun') {\n\t\treturn 'bun install';\n\t}\n\treturn `${pkgManager} install --color always`;\n}\n","import { logger } from '@docusaurus/logger';\nimport prompts from 'prompts';\nimport shell from 'shelljs';\nimport { defaultJavaScriptRuntime, type JavaScriptRuntime } from './constants.ts';\n\nexport async function getRuntime(): Promise<JavaScriptRuntime> {\n\tconst hasBun = shell.exec('bun --version', { silent: true }).code === 0;\n\tconst hasDeno = shell.exec('deno --version', { silent: true }).code === 0;\n\n\tif (!hasDeno && !hasBun) {\n\t\treturn 'node';\n\t}\n\tconst choices = ['node', hasBun && 'bun', hasDeno && 'deno']\n\t\t.filter((p) => p !== false)\n\t\t.map((p) => ({ title: p, value: p }));\n\n\tconst runtime = await prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'runtime',\n\t\t\tmessage: 'Select a runtime...',\n\t\t\tchoices,\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.info`Falling back to name=${defaultJavaScriptRuntime}`;\n\t\t\t},\n\t\t},\n\t).then((result) => (result as { runtime?: JavaScriptRuntime }).runtime);\n\n\treturn runtime ?? defaultJavaScriptRuntime;\n}\n","{\n \"name\": \"@baeta/template-apollo\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"baeta generate\",\n \"start\": \"baeta generate --watch --run='node --watch --enable-source-maps --inspect src/app.ts'\"\n },\n \"dependencies\": {\n \"@apollo/server\": \"^5.2.0\",\n \"@baeta/core\": \"workspace:^\",\n \"@baeta/errors\": \"workspace:^\",\n \"@baeta/extension-complexity\": \"workspace:^\",\n \"graphql\": \"^16.12.0\"\n },\n \"devDependencies\": {\n \"@baeta/cli\": \"workspace:^\",\n \"@types/bun\": \"^1.3.3\",\n \"@types/deno\": \"^2.5.0\",\n \"@types/node\": \"^22.19.1\",\n \"typescript\": \"^5.9.3\"\n }\n}\n","{\n \"$schema\": \"https://json.schemastore.org/tsconfig\",\n \"compilerOptions\": {\n \"target\": \"es2024\",\n \"lib\": [\n \"es2024\"\n ],\n \"noEmit\": true,\n \"types\": [],\n \"module\": \"esnext\",\n \"moduleResolution\": \"bundler\",\n \"strict\": true,\n \"noImplicitAny\": true,\n \"erasableSyntaxOnly\": true,\n \"isolatedModules\": true,\n \"esModuleInterop\": true,\n \"verbatimModuleSyntax\": true,\n \"allowImportingTsExtensions\": true,\n \"allowSyntheticDefaultImports\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true\n }\n}\n","{\n \"@baeta/cli\": \"2.0.0-next.11\",\n \"@baeta/core\": \"2.0.0-next.11\",\n \"create-baeta\": \"2.0.0-next.11\",\n \"@baeta/directives\": \"2.0.0-next.11\",\n \"@baeta/env\": \"2.0.0-next.11\",\n \"@baeta/errors\": \"2.0.0-next.11\",\n \"@baeta/extension-auth\": \"2.0.0-next.11\",\n \"@baeta/extension-cache\": \"2.0.0-next.11\",\n \"@baeta/extension-cache-cloudflare\": \"2.0.0-next.11\",\n \"@baeta/extension-cache-keyv\": \"2.0.0-next.11\",\n \"@baeta/extension-cache-redis\": \"2.0.0-next.11\",\n \"@baeta/extension-cache-upstash\": \"2.0.0-next.11\",\n \"@baeta/extension-complexity\": \"2.0.0-next.11\",\n \"@baeta/generator\": \"2.0.0-next.4\",\n \"@baeta/generator-sdk\": \"2.0.0-next.4\",\n \"@baeta/plugin\": \"2.0.0-next.3\",\n \"@baeta/plugin-cloudflare\": \"2.0.0-next.11\",\n \"@baeta/plugin-directives\": \"2.0.0-next.11\",\n \"@baeta/plugin-exec\": \"2.0.0-next.11\",\n \"@baeta/plugin-gitignore\": \"2.0.0-next.11\",\n \"@baeta/plugin-graphql\": \"2.0.0-next.11\",\n \"@baeta/plugin-pagination\": \"2.0.0-next.11\",\n \"@baeta/plugin-prisma\": \"2.0.0-next.11\",\n \"@baeta/subscriptions-cloudflare\": \"0.2.0-next.2\",\n \"@baeta/subscriptions-pubsub\": \"2.0.0-next.11\",\n \"@baeta/util-encoding\": \"2.0.0-next.3\",\n \"@baeta/util-env\": \"2.0.0-next.3\",\n \"@baeta/util-log\": \"2.0.0-next.3\",\n \"@baeta/util-path\": \"2.0.0-next.3\"\n}","import tsconfig from '../../../tools/tsconfig/tsconfig.json';\nimport type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\nimport dependenciesVersions from '../versions.json';\n\nexport type PackageJson = {\n\tname: string;\n\tscripts: Record<string, string | undefined>;\n\tdependencies: Record<string, string | undefined>;\n\tdevDependencies: Record<string, string | undefined>;\n};\n\nexport function makeSharedTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\tpackageJson: PackageJson,\n): TemplateFile[] {\n\treturn [\n\t\tmakePackageJson(appName, runtime, packageJson),\n\t\t{\n\t\t\trelativePath: './tsconfig.json',\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\t...tsconfig,\n\t\t\t\t\tcompilerOptions: {\n\t\t\t\t\t\t...tsconfig.compilerOptions,\n\t\t\t\t\t\trootDir: 'src',\n\t\t\t\t\t\toutDir: 'dist',\n\t\t\t\t\t\tnoEmit: true,\n\t\t\t\t\t\temitDeclarationOnly: false,\n\t\t\t\t\t},\n\t\t\t\t\texclude: ['baeta.ts'],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/extensions.ts',\n\t\t\tcontent: `import { createExtensions } from '@baeta/core';\nimport { complexityExtension } from '@baeta/extension-complexity';\nimport type { Context } from '../types/context.ts';\n\nconst complexity = complexityExtension<Context>({\n\tdefaultComplexity: 1,\n\tdefaultListMultiplier: 10,\n\tasync limit(ctx) {\n\t\treturn {\n\t\t\tdepth: 10,\n\t\t\tbreadth: 50,\n\t\t\tcomplexity: 1000,\n\t\t};\n\t},\n});\n\nexport default createExtensions({\n\tcomplexityExtension: complexity\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user/user.gql',\n\t\t\tcontent: `type User {\n\tid: ID!\n\temail: String!\n\tlastName: String!\n\tprofile: String\n\tgivenName: String\n}\n\ninput UserWhereUniqueInput {\n\tid: ID!\n}\n\ntype Query {\n\tuser(where: UserWhereUniqueInput!): User\n\tusers: [User!]\n}\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user/index.ts',\n\t\t\tcontent: `import { UserModule } from './typedef.ts';\n\nconst { Query, User } = UserModule;\n\nconst userQuery = Query.user\n\t.$use(async (next, { args }) => {\n\t\tconst result = await next();\n\t\tconsole.log('Got user:', result, 'for args:', args);\n\t\treturn result;\n\t})\n\t.resolve(({ args }) => {\n\t\treturn {\n\t\t\tid: args.where.id,\n\t\t\temail: 'jon.doe@baeta.io',\n\t\t\tlastName: 'Doe',\n\t\t\tgivenName: null,\n\t\t\tprofile: null,\n\t\t};\n\t});\n\nconst usersQuery = Query.users.resolve(() => {\n\tconst users = Array.from({ length: 10 }).map((_, i) => ({\n\t\tid: i.toString(),\n\t\temail: \\`jon.doe\\${i}@baeta.io\\`,\n\t\tlastName: \\`Doe \\${i}\\`,\n\t\tgivenName: null,\n\t\tprofile: null,\n\t}));\n\treturn users;\n});\n\nexport default UserModule.$schema({\n\tUser: User.$fields({\n\t\tid: User.id.key('id'),\n\t\temail: User.email.key('email'),\n\t\tlastName: User.lastName.key('lastName'),\n\t\tgivenName: User.givenName.key('givenName').undefinedAsNull(),\n\t\tprofile: User.profile.key('profile').undefinedAsNull(),\n\t}),\n\tQuery: Query.$fields({\n\t\tuser: userQuery,\n\t\tusers: usersQuery,\n\t}),\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user-photos/user-photos.gql',\n\t\t\tcontent: `type UserPhoto {\n\tid: ID!\n\tuserId: ID!\n\turl: String!\n}\n\nextend type User {\n\tphotos: [UserPhoto!]\n}\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/user-photos/index.ts',\n\t\t\tcontent: `import { UserPhotosModule } from './typedef.ts';\n\nconst { User, UserPhoto } = UserPhotosModule;\n\nexport default UserPhotosModule.$schema({\n\tUser: User.$fields({\n\t\tphotos: User.photos.resolve(({ source }) => {\n\t\t\treturn Array.from({ length: 10 }).map((_, i) => ({\n\t\t\t\tid: \\`u\\${source.id}_p\\${i}\\`,\n\t\t\t\tuserId: source.id,\n\t\t\t\turl: \\`https://baeta.io/user/\\${source.id}/photo/\\${i}.png\\`,\n\t\t\t}));\n\t\t}),\n\t}),\n\tUserPhoto: UserPhoto.$fields({\n\t\tid: UserPhoto.id.key('id'),\n\t\turl: UserPhoto.url.key('url'),\n\t\tuserId: UserPhoto.userId.key('userId'),\n\t}),\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/modules/types.ts',\n\t\t\tcontent: `import type { GraphQLResolveInfo } from 'graphql';\nimport type { BaseObjectTypes, BaseScalars } from '../__generated__/utility.ts';\nimport type { Context } from '../types/context.ts';\n\nexport interface Scalars extends BaseScalars {}\n\nexport interface ObjectTypes extends BaseObjectTypes {\n\tUser: {\n\t\tid: string;\n\t\temail: string;\n\t\tlastName: string;\n\t\tgivenName?: string | null;\n\t\tprofile?: string | null;\n\t};\n}\n\nexport type Ctx = Context;\n\nexport type Info = GraphQLResolveInfo;\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './baeta.ts',\n\t\t\tcontent: `import { defineConfig } from '@baeta/cli';\n\nexport default defineConfig({\n\tgraphql: {\n\t\tschemas: ['src/**/*.gql'],\n\t},\n});\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './.gitignore',\n\t\t\tcontent: `# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional stylelint cache\n.stylelintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variable files\n.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# vuepress v2.x temp and cache directory\n.temp\n.cache\n\n# vitepress build output\n**/.vitepress/dist\n\n# vitepress cache directory\n**/.vitepress/cache\n\n# Docusaurus cache and generated files\n.docusaurus\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*\n`,\n\t\t},\n\t];\n}\n\nfunction makePackageJson(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\tpackageJson: {\n\t\tname: string;\n\t\tscripts: Record<string, string | undefined>;\n\t\tdependencies: Record<string, string | undefined>;\n\t\tdevDependencies: Record<string, string | undefined>;\n\t},\n) {\n\tconst meta = structuredClone(packageJson);\n\n\tfor (const [dep, version] of Object.entries(dependenciesVersions)) {\n\t\tif (dep in meta.dependencies) {\n\t\t\tmeta.dependencies[dep] = version;\n\t\t} else if (dep in packageJson.devDependencies) {\n\t\t\tmeta.devDependencies[dep] = version;\n\t\t}\n\t}\n\n\tif (runtime === 'node') {\n\t\tmeta.devDependencies['@types/bun'] = undefined;\n\t\tmeta.devDependencies['@types/deno'] = undefined;\n\t}\n\n\tif (runtime === 'bun') {\n\t\tmeta.scripts.start = `baeta generate --watch --run='bun --watch --inspect src/app.ts'`;\n\t\tmeta.devDependencies['@types/node'] = undefined;\n\t\tmeta.devDependencies['@types/deno'] = undefined;\n\t}\n\n\tif (runtime === 'deno') {\n\t\tmeta.scripts.start = `baeta generate --watch --run='deno --watch --allow-env --allow-read --allow-net src/app.ts'`;\n\t\tmeta.devDependencies['@types/node'] = undefined;\n\t\tmeta.devDependencies['@types/bun'] = undefined;\n\t}\n\n\tmeta.name = appName;\n\n\treturn {\n\t\trelativePath: './package.json',\n\t\tcontent: JSON.stringify(meta, null, 2),\n\t};\n}\n","import type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\nimport apolloPackageJson from '../meta/apollo/package.json';\nimport { makeSharedTemplate } from './shared.ts';\n\nexport async function makeApolloTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n): Promise<TemplateFile[]> {\n\treturn [\n\t\t...makeSharedTemplate(appName, runtime, apolloPackageJson),\n\t\t{\n\t\t\trelativePath: './src/types/context.ts',\n\t\t\tcontent: `export type Context = {\n\tuserId?: string;\n};\n`,\n\t\t},\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { ApolloServer } from '@apollo/server';\nimport { startStandaloneServer } from '@apollo/server/standalone';\nimport { createApplication } from '@baeta/core';\nimport modules from './modules/index.ts';\nimport type { Context } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nconst server = new ApolloServer<Context>({\n\tschema: baeta.schema,\n});\n\nconst { url } = await startStandaloneServer(server, {\n\tlisten: { port: 4000 },\n});\n\nconsole.log(\\`🚀 Server ready at: \\${url}\\`);\n`,\n\t\t},\n\t];\n}\n","{\n \"name\": \"@baeta/template-yoga\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"baeta generate\",\n \"start\": \"baeta generate --watch --run='node --watch --enable-source-maps --inspect src/app.ts'\"\n },\n \"dependencies\": {\n \"@baeta/core\": \"workspace:^\",\n \"@baeta/errors\": \"workspace:^\",\n \"@baeta/extension-complexity\": \"workspace:^\",\n \"graphql\": \"^16.12.0\",\n \"graphql-yoga\": \"^5.17.0\"\n },\n \"devDependencies\": {\n \"@baeta/cli\": \"workspace:^\",\n \"@types/bun\": \"^1.3.3\",\n \"@types/deno\": \"^2.5.0\",\n \"@types/node\": \"^22.19.1\",\n \"typescript\": \"^5.9.3\"\n }\n}\n","import type { JavaScriptRuntime } from '../lib/constants.ts';\nimport type { TemplateFile } from '../lib/template-file.ts';\nimport yogaPackageJson from '../meta/yoga/package.json';\nimport { makeSharedTemplate } from './shared.ts';\n\nexport async function makeYogaTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n): Promise<TemplateFile[]> {\n\treturn [\n\t\t...makeSharedTemplate(appName, runtime, yogaPackageJson),\n\t\t...makeRuntimeFiles(runtime),\n\t\t{\n\t\t\trelativePath: './src/types/context.ts',\n\t\t\tcontent: `export type Context = {\n\tappVersion: string;\n};\n\nexport type ServerContext = {};\n`,\n\t\t},\n\t];\n}\n\nfunction makeRuntimeFiles(runtime: JavaScriptRuntime): TemplateFile[] {\n\tswitch (runtime) {\n\t\tcase 'bun':\n\t\t\treturn makeBunFiles();\n\t\tcase 'deno':\n\t\t\treturn makeDenoFiles();\n\t\tcase 'node':\n\t\t\treturn makeNodeFiles();\n\t\tdefault:\n\t\t\treturn [] satisfies never[];\n\t}\n}\n\nfunction makeBunFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nBun.serve({\n\tfetch: yoga.fetch,\n\tport: 4000,\n});\n\nconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n`,\n\t\t},\n\t];\n}\n\nfunction makeDenoFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nDeno.serve(\n\t{\n\t\tport: 4000,\n\t\tonListen() {\n\t\t\tconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n\t\t},\n\t},\n\tyoga.fetch,\n);\n`,\n\t\t},\n\t];\n}\n\nfunction makeNodeFiles(): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\trelativePath: './src/app.ts',\n\t\t\tcontent: `import { createServer } from 'node:http';\nimport { createApplication } from '@baeta/core';\nimport { createYoga } from 'graphql-yoga';\nimport modules from './modules/index.ts';\nimport type { Context, ServerContext } from './types/context.ts';\n\nconst baeta = createApplication({\n\tmodules,\n});\n\nexport const yoga = createYoga<ServerContext, Context>({\n\tschema: baeta.schema,\n\tcontext: {\n\t\tappVersion: '1.0.0',\n\t},\n});\n\nconst server = createServer(yoga);\n\nserver.listen(4000, () => {\n\tconsole.log(\\`🚀 Server ready at http://localhost:4000\\${yoga.graphqlEndpoint}\\`);\n});\n`,\n\t\t},\n\t];\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport fs from 'fs-extra';\nimport prompts, { type Choice } from 'prompts';\nimport { makeApolloTemplate } from '../templates/apollo.ts';\nimport { makeYogaTemplate } from '../templates/yoga.ts';\nimport { type JavaScriptRuntime, type Template, templates } from './constants.ts';\n\nfunction createTemplateChoices(): Choice[] {\n\treturn templates.map((template) => ({ title: template, value: template }));\n}\n\nasync function askTemplateChoice() {\n\treturn prompts(\n\t\t{\n\t\t\ttype: 'select',\n\t\t\tname: 'template',\n\t\t\tmessage: 'Select a template below...',\n\t\t\tchoices: createTemplateChoices(),\n\t\t},\n\t\t{\n\t\t\tonCancel() {\n\t\t\t\tlogger.error('A choice is required.');\n\t\t\t\tprocess.exit(1);\n\t\t\t},\n\t\t},\n\t).then((result) => {\n\t\treturn (result as { template: Template }).template;\n\t});\n}\n\nexport async function getTemplate(reqTemplate: string | undefined) {\n\tconst userProvided = reqTemplate ? templates.find((t) => t === reqTemplate) : null;\n\tconst template = userProvided ?? (await askTemplateChoice());\n\n\tif (!template) {\n\t\tthrow new Error('Template not found');\n\t}\n\n\treturn template;\n}\n\nfunction getTemplateFiles(template: Template, appName: string, runtime: JavaScriptRuntime) {\n\tswitch (template) {\n\t\tcase 'yoga':\n\t\t\treturn makeYogaTemplate(appName, runtime);\n\t\tcase 'apollo':\n\t\t\treturn makeApolloTemplate(appName, runtime);\n\t\tdefault:\n\t\t\treturn [] satisfies never[];\n\t}\n}\n\nexport async function copyTemplate(\n\tappName: string,\n\truntime: JavaScriptRuntime,\n\ttemplate: Template,\n\tdest: string,\n) {\n\tconst files = await getTemplateFiles(template, appName, runtime);\n\n\tconst promises = files.map((file) => {\n\t\tconst filePath = path.join(dest, file.relativePath);\n\t\treturn fs.ensureDir(path.dirname(filePath)).then(() => fs.writeFile(filePath, file.content));\n\t});\n\n\tawait Promise.all(promises);\n}\n","import path from 'node:path';\nimport { logger } from '@docusaurus/logger';\nimport shell from 'shelljs';\nimport supportsColor from 'supports-color';\nimport { getAppName } from './app-name.ts';\nimport type { PackageManager } from './constants.ts';\nimport { getInstallCommand, getPackageManager } from './package-manager.ts';\nimport { getRuntime } from './runtime.ts';\nimport { copyTemplate, getTemplate } from './templates.ts';\n\nexport interface Args {\n\tpackageManager?: PackageManager;\n\tskipInstall?: boolean;\n\tappName?: string;\n\ttemplate?: string;\n\trootDir: string;\n}\n\nexport async function handler(args: Args) {\n\tconst appName = await getAppName(args.appName, args.rootDir);\n\tconst dest = path.resolve(args.rootDir, appName);\n\n\tconst template = await getTemplate(args.template);\n\n\tconst runtime = await getRuntime();\n\n\tlogger.info('Creating new Baeta project...');\n\n\ttry {\n\t\tawait copyTemplate(appName, runtime, template, dest);\n\t} catch (err) {\n\t\tlogger.error`Copying Baeta template name=${template} failed!`;\n\t\tthrow err;\n\t}\n\n\tconst pkgManager = await getPackageManager(dest, args);\n\n\tconst useNpm = pkgManager === 'npm';\n\tconst useBun = pkgManager === 'bun';\n\tconst useRunCommand = useNpm || useBun;\n\tconst runCommand = useRunCommand ? 'run ' : '';\n\n\tconst start = `${pkgManager} start`;\n\tconst build = `${pkgManager} ${runCommand}build`;\n\tconst cd = `cd ${dest}`;\n\tconst install = `${pkgManager} install`;\n\n\tif (!args.skipInstall) {\n\t\tshell.cd(dest);\n\t\tlogger.info`Installing dependencies with name=${pkgManager}...`;\n\t\tconst result = shell.exec(getInstallCommand(pkgManager), {\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...(supportsColor.stdout ? { FORCE_COLOR: '1' } : {}),\n\t\t\t},\n\t\t});\n\n\t\tif (result.code !== 0) {\n\t\t\tconsole.error('Dependency installation failed.');\n\t\t\tlogger.error('Dependency installation failed.');\n\t\t\tlogger.info`The app directory has already been created, and you can retry by typing:\n\ncode=${cd}\ncode=${install}`;\n\n\t\t\tprocess.exit(0);\n\t\t}\n\t}\n\n\tlogger.success`Created name=${dest}.`;\n\n\tlogger.info`Inside that directory, you can run several commands:\n\n code=${start}\n Starts the development server.\n\n code=${build}\n Generates the Baeta application.\n\nWe recommend that you begin by typing:\n\n code=${cd}\n code=${start}\n`;\n}\n"],"mappings":";;;;;;;;AAAA,MAAa,wBAAwB;AAErC,MAAa,gBAAgB;CAC5B,KAAK;CACL,MAAM;CACN,MAAM;CACN,KAAK;CACL;AAED,MAAa,kBAAkB,OAAO,KAAK,cAAc;AAIzD,MAAa,WAAW;CAAC;CAAQ;CAAQ;CAAM;AAI/C,MAAa,2BAA2B;AAExC,MAAa,YAAY,CAAC,QAAQ,SAAS;;;;ACd3C,eAAsB,WAAW,SAA6B,SAAkC;CAC/F,eAAe,gBAAgB,SAAiB;AAC/C,MAAI,CAAC,QACJ,QAAO;EAER,MAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ;AAC3C,MAAI,MAAM,GAAG,WAAW,KAAK,CAC5B,QAAO,OAAO,WAAW,oCAAoC,KAAK;AAEnE,SAAO;;AAGR,KAAI,SAAS;EACZ,MAAM,MAAM,MAAM,gBAAgB,QAAQ;AAC1C,MAAI,OAAO,QAAQ,SAClB,OAAM,IAAI,UAAU,IAAI;AAEzB,SAAO;;AAGR,QAAO,QACN;EACC,MAAM;EACN,MAAM;EACN,SAAS;EACT,SAAS;EACT,UAAU;EACV,EACD,EACC,WAAW;AACV,SAAO,MAAM,2BAA2B;AACxC,UAAQ,KAAK,EAAE;IAEhB,CACD,CAAC,MAAM,WAAY,OAA+B,QAAQ;;;;;AC1B5D,eAAe,+BACd,SACsC;AACtC,MAAK,MAAM,kBAAkB,iBAAiB;EAC7C,MAAM,eAAe,KAAK,KAAK,SAAS,cAAc,gBAAgB;AACtE,MAAI,MAAM,GAAG,WAAW,aAAa,CACpC,QAAO;;;AAMV,SAAS,kCAA8D;AACtE,QAAO,gBAAgB,MAAM,mBAC5B,QAAQ,IAAI,uBAAuB,WAAW,eAAe,CAC7D;;AAGF,eAAe,6BAAsD;CACpE,MAAM,UAAU,M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M,WAAW,MAAM,YAAY,KAAK,SAAS;CAEjD,MAAM,UAAU,MAAM,YAAY;AAElC,QAAO,KAAK,gCAAgC;AAE5C,KAAI;AACH,QAAM,aAAa,SAAS,SAAS,UAAU,KAAK;UAC5C,KAAK;AACb,SAAO,KAAK,+BAA+B,SAAS;AACpD,QAAM;;CAGP,MAAM,aAAa,MAAM,kBAAkB,MAAM,KAAK;CAKtD,MAAM,aAHS,eAAe,SACf,eAAe,QAEK,SAAS;CAE5C,MAAM,QAAQ,GAAG,WAAW;CAC5B,MAAM,QAAQ,GAAG,WAAW,GAAG,WAAW;CAC1C,MAAM,KAAK,MAAM;CACjB,MAAM,UAAU,GAAG,WAAW;AAE9B,KAAI,CAAC,KAAK,aAAa;AACtB,QAAM,GAAG,KAAK;AACd,SAAO,IAAI,qCAAqC,WAAW;AAQ3D,MAPe,MAAM,KAAK,kBAAkB,WAAW,EAAE,EACxD,KAAK;GACJ,GAAG,QAAQ;GACX,GAAI,cAAc,SAAS,EAAE,aAAa,KAAK,GAAG,EAAE;GACpD,EACD,CAAC,CAES,SAAS,GAAG;AACtB,WAAQ,MAAM,kCAAkC;AAChD,UAAO,MAAM,kCAAkC;AAC/C,UAAO,IAAI;;OAEP,GAAG;OACH;AAEJ,WAAQ,KAAK,EAAE;;;AAIjB,QAAO,OAAO,gBAAgB,KAAK;AAEnC,QAAO,IAAI;;SAEH,MAAM;;;SAGN,MAAM;;;;;SAKN,GAAG;SACH,MAAM"}
@@ -1,43 +0,0 @@
1
- import type { JavaScriptRuntime } from '../lib/constants.ts';
2
- import type { TemplateFile } from '../lib/template-file.ts';
3
- import apolloPackageJson from '../meta/apollo/package.json';
4
- import { makeSharedTemplate } from './shared.ts';
5
-
6
- export async function makeApolloTemplate(
7
- appName: string,
8
- runtime: JavaScriptRuntime,
9
- ): Promise<TemplateFile[]> {
10
- return [
11
- ...makeSharedTemplate(appName, runtime, apolloPackageJson),
12
- {
13
- relativePath: './src/types/context.ts',
14
- content: `export type Context = {
15
- userId?: string;
16
- };
17
- `,
18
- },
19
- {
20
- relativePath: './src/app.ts',
21
- content: `import { ApolloServer } from '@apollo/server';
22
- import { startStandaloneServer } from '@apollo/server/standalone';
23
- import { createApplication } from '@baeta/core';
24
- import modules from './modules/index.ts';
25
- import type { Context } from './types/context.ts';
26
-
27
- const baeta = createApplication({
28
- modules,
29
- });
30
-
31
- const server = new ApolloServer<Context>({
32
- schema: baeta.schema,
33
- });
34
-
35
- const { url } = await startStandaloneServer(server, {
36
- listen: { port: 4000 },
37
- });
38
-
39
- console.log(\`🚀 Server ready at: \${url}\`);
40
- `,
41
- },
42
- ];
43
- }
@@ -1,386 +0,0 @@
1
- import tsconfig from '../../../tools/tsconfig/tsconfig.json';
2
- import type { JavaScriptRuntime } from '../lib/constants.ts';
3
- import type { TemplateFile } from '../lib/template-file.ts';
4
- import dependenciesVersions from '../versions.json';
5
-
6
- export type PackageJson = {
7
- name: string;
8
- scripts: Record<string, string | undefined>;
9
- dependencies: Record<string, string | undefined>;
10
- devDependencies: Record<string, string | undefined>;
11
- };
12
-
13
- export function makeSharedTemplate(
14
- appName: string,
15
- runtime: JavaScriptRuntime,
16
- packageJson: PackageJson,
17
- ): TemplateFile[] {
18
- return [
19
- makePackageJson(appName, runtime, packageJson),
20
- {
21
- relativePath: './tsconfig.json',
22
- content: JSON.stringify(
23
- {
24
- ...tsconfig,
25
- compilerOptions: {
26
- ...tsconfig.compilerOptions,
27
- rootDir: 'src',
28
- outDir: 'dist',
29
- noEmit: true,
30
- emitDeclarationOnly: false,
31
- },
32
- exclude: ['baeta.ts'],
33
- },
34
- null,
35
- 2,
36
- ),
37
- },
38
- {
39
- relativePath: './src/modules/extensions.ts',
40
- content: `import { createExtensions } from '@baeta/core';
41
- import { complexityExtension } from '@baeta/extension-complexity';
42
- import type { Context } from '../types/context.ts';
43
-
44
- const complexity = complexityExtension<Context>({
45
- defaultComplexity: 1,
46
- defaultListMultiplier: 10,
47
- async limit(ctx) {
48
- return {
49
- depth: 10,
50
- breadth: 50,
51
- complexity: 1000,
52
- };
53
- },
54
- });
55
-
56
- export default createExtensions({
57
- complexityExtension: complexity
58
- });
59
- `,
60
- },
61
- {
62
- relativePath: './src/modules/user/user.gql',
63
- content: `type User {
64
- id: ID!
65
- email: String!
66
- lastName: String!
67
- profile: String
68
- givenName: String
69
- }
70
-
71
- input UserWhereUniqueInput {
72
- id: ID!
73
- }
74
-
75
- type Query {
76
- user(where: UserWhereUniqueInput!): User
77
- users: [User!]
78
- }
79
- `,
80
- },
81
- {
82
- relativePath: './src/modules/user/index.ts',
83
- content: `import { UserModule } from './typedef.ts';
84
-
85
- const { Query, User } = UserModule;
86
-
87
- const userQuery = Query.user
88
- .$use(async (next, { args }) => {
89
- const result = await next();
90
- console.log('Got user:', result, 'for args:', args);
91
- return result;
92
- })
93
- .resolve(({ args }) => {
94
- return {
95
- id: args.where.id,
96
- email: 'jon.doe@baeta.io',
97
- lastName: 'Doe',
98
- givenName: null,
99
- profile: null,
100
- };
101
- });
102
-
103
- const usersQuery = Query.users.resolve(() => {
104
- const users = Array.from({ length: 10 }).map((_, i) => ({
105
- id: i.toString(),
106
- email: \`jon.doe\${i}@baeta.io\`,
107
- lastName: \`Doe \${i}\`,
108
- givenName: null,
109
- profile: null,
110
- }));
111
- return users;
112
- });
113
-
114
- export default UserModule.$schema({
115
- User: User.$fields({
116
- id: User.id.key('id'),
117
- email: User.email.key('email'),
118
- lastName: User.lastName.key('lastName'),
119
- givenName: User.givenName.key('givenName').undefinedAsNull(),
120
- profile: User.profile.key('profile').undefinedAsNull(),
121
- }),
122
- Query: Query.$fields({
123
- user: userQuery,
124
- users: usersQuery,
125
- }),
126
- });
127
- `,
128
- },
129
- {
130
- relativePath: './src/modules/user-photos/user-photos.gql',
131
- content: `type UserPhoto {
132
- id: ID!
133
- userId: ID!
134
- url: String!
135
- }
136
-
137
- extend type User {
138
- photos: [UserPhoto!]
139
- }
140
- `,
141
- },
142
- {
143
- relativePath: './src/modules/user-photos/index.ts',
144
- content: `import { UserPhotosModule } from './typedef.ts';
145
-
146
- const { User, UserPhoto } = UserPhotosModule;
147
-
148
- export default UserPhotosModule.$schema({
149
- User: User.$fields({
150
- photos: User.photos.resolve(({ source }) => {
151
- return Array.from({ length: 10 }).map((_, i) => ({
152
- id: \`u\${source.id}_p\${i}\`,
153
- userId: source.id,
154
- url: \`https://baeta.io/user/\${source.id}/photo/\${i}.png\`,
155
- }));
156
- }),
157
- }),
158
- UserPhoto: UserPhoto.$fields({
159
- id: UserPhoto.id.key('id'),
160
- url: UserPhoto.url.key('url'),
161
- userId: UserPhoto.userId.key('userId'),
162
- }),
163
- });
164
- `,
165
- },
166
- {
167
- relativePath: './src/modules/types.ts',
168
- content: `import type { GraphQLResolveInfo } from 'graphql';
169
- import type { BaseObjectTypes, BaseScalars } from '../__generated__/utility.ts';
170
- import type { Context } from '../types/context.ts';
171
-
172
- export interface Scalars extends BaseScalars {}
173
-
174
- export interface ObjectTypes extends BaseObjectTypes {
175
- User: {
176
- id: string;
177
- email: string;
178
- lastName: string;
179
- givenName?: string | null;
180
- profile?: string | null;
181
- };
182
- }
183
-
184
- export type Ctx = Context;
185
-
186
- export type Info = GraphQLResolveInfo;
187
- `,
188
- },
189
- {
190
- relativePath: './baeta.ts',
191
- content: `import { defineConfig } from '@baeta/cli';
192
-
193
- export default defineConfig({
194
- graphql: {
195
- schemas: ['src/**/*.gql'],
196
- },
197
- });
198
- `,
199
- },
200
- {
201
- relativePath: './.gitignore',
202
- content: `# Logs
203
- logs
204
- *.log
205
- npm-debug.log*
206
- yarn-debug.log*
207
- yarn-error.log*
208
- lerna-debug.log*
209
- .pnpm-debug.log*
210
-
211
- # Diagnostic reports (https://nodejs.org/api/report.html)
212
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
213
-
214
- # Runtime data
215
- pids
216
- *.pid
217
- *.seed
218
- *.pid.lock
219
-
220
- # Directory for instrumented libs generated by jscoverage/JSCover
221
- lib-cov
222
-
223
- # Coverage directory used by tools like istanbul
224
- coverage
225
- *.lcov
226
-
227
- # nyc test coverage
228
- .nyc_output
229
-
230
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
231
- .grunt
232
-
233
- # Bower dependency directory (https://bower.io/)
234
- bower_components
235
-
236
- # node-waf configuration
237
- .lock-wscript
238
-
239
- # Compiled binary addons (https://nodejs.org/api/addons.html)
240
- build/Release
241
-
242
- # Dependency directories
243
- node_modules/
244
- jspm_packages/
245
-
246
- # Snowpack dependency directory (https://snowpack.dev/)
247
- web_modules/
248
-
249
- # TypeScript cache
250
- *.tsbuildinfo
251
-
252
- # Optional npm cache directory
253
- .npm
254
-
255
- # Optional eslint cache
256
- .eslintcache
257
-
258
- # Optional stylelint cache
259
- .stylelintcache
260
-
261
- # Microbundle cache
262
- .rpt2_cache/
263
- .rts2_cache_cjs/
264
- .rts2_cache_es/
265
- .rts2_cache_umd/
266
-
267
- # Optional REPL history
268
- .node_repl_history
269
-
270
- # Output of 'npm pack'
271
- *.tgz
272
-
273
- # Yarn Integrity file
274
- .yarn-integrity
275
-
276
- # dotenv environment variable files
277
- .env
278
- .env.development.local
279
- .env.test.local
280
- .env.production.local
281
- .env.local
282
-
283
- # parcel-bundler cache (https://parceljs.org/)
284
- .cache
285
- .parcel-cache
286
-
287
- # Next.js build output
288
- .next
289
- out
290
-
291
- # Nuxt.js build / generate output
292
- .nuxt
293
- dist
294
-
295
- # Gatsby files
296
- .cache/
297
- # Comment in the public line in if your project uses Gatsby and not Next.js
298
- # https://nextjs.org/blog/next-9-1#public-directory-support
299
- # public
300
-
301
- # vuepress build output
302
- .vuepress/dist
303
-
304
- # vuepress v2.x temp and cache directory
305
- .temp
306
- .cache
307
-
308
- # vitepress build output
309
- **/.vitepress/dist
310
-
311
- # vitepress cache directory
312
- **/.vitepress/cache
313
-
314
- # Docusaurus cache and generated files
315
- .docusaurus
316
-
317
- # Serverless directories
318
- .serverless/
319
-
320
- # FuseBox cache
321
- .fusebox/
322
-
323
- # DynamoDB Local files
324
- .dynamodb/
325
-
326
- # TernJS port file
327
- .tern-port
328
-
329
- # Stores VSCode versions used for testing VSCode extensions
330
- .vscode-test
331
-
332
- # yarn v2
333
- .yarn/cache
334
- .yarn/unplugged
335
- .yarn/build-state.yml
336
- .yarn/install-state.gz
337
- .pnp.*
338
- `,
339
- },
340
- ];
341
- }
342
-
343
- function makePackageJson(
344
- appName: string,
345
- runtime: JavaScriptRuntime,
346
- packageJson: {
347
- name: string;
348
- scripts: Record<string, string | undefined>;
349
- dependencies: Record<string, string | undefined>;
350
- devDependencies: Record<string, string | undefined>;
351
- },
352
- ) {
353
- const meta = structuredClone(packageJson);
354
-
355
- for (const [dep, version] of Object.entries(dependenciesVersions)) {
356
- if (dep in meta.dependencies) {
357
- meta.dependencies[dep] = version;
358
- } else if (dep in packageJson.devDependencies) {
359
- meta.devDependencies[dep] = version;
360
- }
361
- }
362
-
363
- if (runtime === 'node') {
364
- meta.devDependencies['@types/bun'] = undefined;
365
- meta.devDependencies['@types/deno'] = undefined;
366
- }
367
-
368
- if (runtime === 'bun') {
369
- meta.scripts.start = `baeta generate --watch --run='bun --watch --inspect src/app.ts'`;
370
- meta.devDependencies['@types/node'] = undefined;
371
- meta.devDependencies['@types/deno'] = undefined;
372
- }
373
-
374
- if (runtime === 'deno') {
375
- meta.scripts.start = `baeta generate --watch --run='deno --watch --allow-env --allow-read --allow-net src/app.ts'`;
376
- meta.devDependencies['@types/node'] = undefined;
377
- meta.devDependencies['@types/bun'] = undefined;
378
- }
379
-
380
- meta.name = appName;
381
-
382
- return {
383
- relativePath: './package.json',
384
- content: JSON.stringify(meta, null, 2),
385
- };
386
- }
package/templates/yoga.ts DELETED
@@ -1,132 +0,0 @@
1
- import type { JavaScriptRuntime } from '../lib/constants.ts';
2
- import type { TemplateFile } from '../lib/template-file.ts';
3
- import yogaPackageJson from '../meta/yoga/package.json';
4
- import { makeSharedTemplate } from './shared.ts';
5
-
6
- export async function makeYogaTemplate(
7
- appName: string,
8
- runtime: JavaScriptRuntime,
9
- ): Promise<TemplateFile[]> {
10
- return [
11
- ...makeSharedTemplate(appName, runtime, yogaPackageJson),
12
- ...makeRuntimeFiles(runtime),
13
- {
14
- relativePath: './src/types/context.ts',
15
- content: `export type Context = {
16
- appVersion: string;
17
- };
18
-
19
- export type ServerContext = {};
20
- `,
21
- },
22
- ];
23
- }
24
-
25
- function makeRuntimeFiles(runtime: JavaScriptRuntime): TemplateFile[] {
26
- switch (runtime) {
27
- case 'bun':
28
- return makeBunFiles();
29
- case 'deno':
30
- return makeDenoFiles();
31
- case 'node':
32
- return makeNodeFiles();
33
- default:
34
- return [] satisfies never[];
35
- }
36
- }
37
-
38
- function makeBunFiles(): TemplateFile[] {
39
- return [
40
- {
41
- relativePath: './src/app.ts',
42
- content: `import { createApplication } from '@baeta/core';
43
- import { createYoga } from 'graphql-yoga';
44
- import modules from './modules/index.ts';
45
- import type { Context, ServerContext } from './types/context.ts';
46
-
47
- const baeta = createApplication({
48
- modules,
49
- });
50
-
51
- export const yoga = createYoga<ServerContext, Context>({
52
- schema: baeta.schema,
53
- context: {
54
- appVersion: '1.0.0',
55
- },
56
- });
57
-
58
- Bun.serve({
59
- fetch: yoga.fetch,
60
- port: 4000,
61
- });
62
-
63
- console.log(\`🚀 Server ready at http://localhost:4000\${yoga.graphqlEndpoint}\`);
64
- `,
65
- },
66
- ];
67
- }
68
-
69
- function makeDenoFiles(): TemplateFile[] {
70
- return [
71
- {
72
- relativePath: './src/app.ts',
73
- content: `import { createApplication } from '@baeta/core';
74
- import { createYoga } from 'graphql-yoga';
75
- import modules from './modules/index.ts';
76
- import type { Context, ServerContext } from './types/context.ts';
77
-
78
- const baeta = createApplication({
79
- modules,
80
- });
81
-
82
- export const yoga = createYoga<ServerContext, Context>({
83
- schema: baeta.schema,
84
- context: {
85
- appVersion: '1.0.0',
86
- },
87
- });
88
-
89
- Deno.serve(
90
- {
91
- port: 4000,
92
- onListen() {
93
- console.log(\`🚀 Server ready at http://localhost:4000\${yoga.graphqlEndpoint}\`);
94
- },
95
- },
96
- yoga.fetch,
97
- );
98
- `,
99
- },
100
- ];
101
- }
102
-
103
- function makeNodeFiles(): TemplateFile[] {
104
- return [
105
- {
106
- relativePath: './src/app.ts',
107
- content: `import { createServer } from 'node:http';
108
- import { createApplication } from '@baeta/core';
109
- import { createYoga } from 'graphql-yoga';
110
- import modules from './modules/index.ts';
111
- import type { Context, ServerContext } from './types/context.ts';
112
-
113
- const baeta = createApplication({
114
- modules,
115
- });
116
-
117
- export const yoga = createYoga<ServerContext, Context>({
118
- schema: baeta.schema,
119
- context: {
120
- appVersion: '1.0.0',
121
- },
122
- });
123
-
124
- const server = createServer(yoga);
125
-
126
- server.listen(4000, () => {
127
- console.log(\`🚀 Server ready at http://localhost:4000\${yoga.graphqlEndpoint}\`);
128
- });
129
- `,
130
- },
131
- ];
132
- }