create-sprint 0.0.84 → 0.0.88

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/dist/index.js CHANGED
@@ -48,7 +48,9 @@ export async function runCLI(args) {
48
48
  { value: "open-telemetry", label: "OpenTelemetry", hint: "flexible, open standard", disabled: true },
49
49
  { value: "sentry", label: "Sentry", hint: "free tier available" },
50
50
  { value: "glitchtip", label: "GlitchTip", hint: "self-hostable" },
51
- { value: "discord", label: "Discord Webhook", hint: "sends to a channel" }
51
+ { value: "discord", label: "Discord Webhook", hint: "sends to a channel" },
52
+ { value: "telegram", label: "Telegram Bot", hint: "sends to a chat", disabled: true },
53
+ { value: "nodemailer", label: "Nodemailer", hint: "sends emails", disabled: true }
52
54
  ]
53
55
  }),
54
56
  swagger: () => p.confirm({ message: "Add Swagger UI & OpenAPI?", initialValue: true }),
@@ -1,8 +1,18 @@
1
1
  export function getGraphQLFiles(language) {
2
2
  const isTs = language === "typescript";
3
3
  const ext = isTs ? "" : ".js";
4
- return {
5
- "types.ts": `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
4
+ const tsTypes = `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
5
+
6
+ export const UserType = new GraphQLObjectType({
7
+ name: "User",
8
+ fields: {
9
+ id: { type: new GraphQLNonNull(GraphQLString) },
10
+ name: { type: GraphQLString },
11
+ email: { type: GraphQLString }
12
+ }
13
+ });
14
+ `;
15
+ const jsTypes = `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
6
16
 
7
17
  export const UserType = new GraphQLObjectType({
8
18
  name: "User",
@@ -12,9 +22,75 @@ export const UserType = new GraphQLObjectType({
12
22
  email: { type: GraphQLString }
13
23
  }
14
24
  });
15
- `,
16
- "resolvers.ts": `import { GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
17
- import { UserType } from "./types${ext}";
25
+ `;
26
+ const tsResolvers = `import {
27
+ GraphQLString,
28
+ GraphQLList,
29
+ GraphQLNonNull
30
+ } from "graphql";
31
+ import { UserType } from "./types";
32
+
33
+ interface User {
34
+ id: string;
35
+ name: string;
36
+ email: string;
37
+ }
38
+
39
+ interface UserArgs {
40
+ id: string;
41
+ }
42
+
43
+ interface CreateUserArgs {
44
+ name: string;
45
+ email: string;
46
+ }
47
+
48
+ export const users: User[] = [
49
+ { id: "1", name: "John Doe", email: "john@example.com" },
50
+ { id: "2", name: "Jane Smith", email: "jane@example.com" }
51
+ ];
52
+
53
+ export const queries = {
54
+ hello: {
55
+ type: GraphQLString,
56
+ resolve: (): string => "Hello, GraphQL!"
57
+ },
58
+ users: {
59
+ type: new GraphQLList(UserType),
60
+ resolve: (): User[] => users
61
+ },
62
+ user: {
63
+ type: UserType,
64
+ args: {
65
+ id: { type: new GraphQLNonNull(GraphQLString) }
66
+ },
67
+ resolve: (_: unknown, args: UserArgs): User | undefined => {
68
+ return users.find(u => u.id === args.id);
69
+ }
70
+ }
71
+ };
72
+
73
+ export const mutations = {
74
+ createUser: {
75
+ type: UserType,
76
+ args: {
77
+ name: { type: new GraphQLNonNull(GraphQLString) },
78
+ email: { type: new GraphQLNonNull(GraphQLString) }
79
+ },
80
+ resolve: (_: unknown, args: CreateUserArgs): User => {
81
+ const newUser: User = {
82
+ id: String(users.length + 1),
83
+ name: args.name,
84
+ email: args.email
85
+ };
86
+ users.push(newUser);
87
+ return newUser;
88
+ }
89
+ }
90
+ };
91
+ `;
92
+ const jsResolvers = `import { GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
93
+ import { UserType } from "./types.js";
18
94
 
19
95
  export const users = [
20
96
  { id: "1", name: "John Doe", email: "john@example.com" },
@@ -53,9 +129,9 @@ export const mutations = {
53
129
  }
54
130
  }
55
131
  };
56
- `,
57
- "schema.ts": `import { GraphQLSchema, GraphQLObjectType } from "graphql";
58
- import { queries, mutations } from "./resolvers${ext}";
132
+ `;
133
+ const tsSchema = `import { GraphQLSchema, GraphQLObjectType } from "graphql";
134
+ import { queries, mutations } from "./resolvers";
59
135
 
60
136
  const Query = new GraphQLObjectType({
61
137
  name: "Query",
@@ -68,6 +144,25 @@ const Mutation = new GraphQLObjectType({
68
144
  });
69
145
 
70
146
  export const graphqlSchema = new GraphQLSchema({ query: Query, mutation: Mutation });
71
- `
147
+ `;
148
+ const jsSchema = `import { GraphQLSchema, GraphQLObjectType } from "graphql";
149
+ import { queries, mutations } from "./resolvers.js";
150
+
151
+ const Query = new GraphQLObjectType({
152
+ name: "Query",
153
+ fields: queries
154
+ });
155
+
156
+ const Mutation = new GraphQLObjectType({
157
+ name: "Mutation",
158
+ fields: mutations
159
+ });
160
+
161
+ export const graphqlSchema = new GraphQLSchema({ query: Query, mutation: Mutation });
162
+ `;
163
+ return {
164
+ "types.ts": isTs ? tsTypes : jsTypes,
165
+ "resolvers.ts": isTs ? tsResolvers : jsResolvers,
166
+ "schema.ts": isTs ? tsSchema : jsSchema
72
167
  };
73
168
  }
@@ -10,7 +10,7 @@ export function generateJWTKeys() {
10
10
  ;
11
11
  export function getTypeScriptPackageJson(name, telemetry, swagger, graphql) {
12
12
  const deps = {
13
- "sprint-es": "^0.0.85"
13
+ "sprint-es": "^0.0.87"
14
14
  };
15
15
  const devDeps = {
16
16
  "@types/node": "^22.0.0",
@@ -49,7 +49,7 @@ export function getTypeScriptPackageJson(name, telemetry, swagger, graphql) {
49
49
  ;
50
50
  export function getJavaScriptPackageJson(name, telemetry, swagger, graphql) {
51
51
  const deps = {
52
- "sprint-es": "^0.0.85"
52
+ "sprint-es": "^0.0.87"
53
53
  };
54
54
  if (telemetry === "sentry" || telemetry === "glitchtip")
55
55
  deps["@sentry/node"] = "^8.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sprint",
3
- "version": "0.0.84",
3
+ "version": "0.0.88",
4
4
  "description": "Create a new Sprint API project",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -75,7 +75,9 @@ export async function runCLI(args: string[]) {
75
75
  { value: "open-telemetry", label: "OpenTelemetry", hint: "flexible, open standard", disabled: true },
76
76
  { value: "sentry", label: "Sentry", hint: "free tier available" },
77
77
  { value: "glitchtip", label: "GlitchTip", hint: "self-hostable" },
78
- { value: "discord", label: "Discord Webhook", hint: "sends to a channel" }
78
+ { value: "discord", label: "Discord Webhook", hint: "sends to a channel" },
79
+ { value: "telegram", label: "Telegram Bot", hint: "sends to a chat", disabled: true },
80
+ { value: "nodemailer", label: "Nodemailer", hint: "sends emails", disabled: true }
79
81
  ]
80
82
  }),
81
83
 
@@ -2,8 +2,7 @@ export function getGraphQLFiles(language: string) {
2
2
  const isTs = language === "typescript";
3
3
  const ext = isTs ? "" : ".js";
4
4
 
5
- return {
6
- "types.ts": `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
5
+ const tsTypes = `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
7
6
 
8
7
  export const UserType = new GraphQLObjectType({
9
8
  name: "User",
@@ -13,9 +12,89 @@ export const UserType = new GraphQLObjectType({
13
12
  email: { type: GraphQLString }
14
13
  }
15
14
  });
16
- `,
17
- "resolvers.ts": `import { GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
18
- import { UserType } from "./types${ext}";
15
+ `;
16
+
17
+ const jsTypes = `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
18
+
19
+ export const UserType = new GraphQLObjectType({
20
+ name: "User",
21
+ fields: {
22
+ id: { type: new GraphQLNonNull(GraphQLString) },
23
+ name: { type: GraphQLString },
24
+ email: { type: GraphQLString }
25
+ }
26
+ });
27
+ `;
28
+
29
+ const tsResolvers = `import {
30
+ GraphQLString,
31
+ GraphQLList,
32
+ GraphQLNonNull
33
+ } from "graphql";
34
+ import { UserType } from "./types";
35
+
36
+ interface User {
37
+ id: string;
38
+ name: string;
39
+ email: string;
40
+ }
41
+
42
+ interface UserArgs {
43
+ id: string;
44
+ }
45
+
46
+ interface CreateUserArgs {
47
+ name: string;
48
+ email: string;
49
+ }
50
+
51
+ export const users: User[] = [
52
+ { id: "1", name: "John Doe", email: "john@example.com" },
53
+ { id: "2", name: "Jane Smith", email: "jane@example.com" }
54
+ ];
55
+
56
+ export const queries = {
57
+ hello: {
58
+ type: GraphQLString,
59
+ resolve: (): string => "Hello, GraphQL!"
60
+ },
61
+ users: {
62
+ type: new GraphQLList(UserType),
63
+ resolve: (): User[] => users
64
+ },
65
+ user: {
66
+ type: UserType,
67
+ args: {
68
+ id: { type: new GraphQLNonNull(GraphQLString) }
69
+ },
70
+ resolve: (_: unknown, args: UserArgs): User | undefined => {
71
+ return users.find(u => u.id === args.id);
72
+ }
73
+ }
74
+ };
75
+
76
+ export const mutations = {
77
+ createUser: {
78
+ type: UserType,
79
+ args: {
80
+ name: { type: new GraphQLNonNull(GraphQLString) },
81
+ email: { type: new GraphQLNonNull(GraphQLString) }
82
+ },
83
+ resolve: (_: unknown, args: CreateUserArgs): User => {
84
+ const newUser: User = {
85
+ id: String(users.length + 1),
86
+ name: args.name,
87
+ email: args.email
88
+ };
89
+ users.push(newUser);
90
+ return newUser;
91
+ }
92
+ }
93
+ };
94
+ `;
95
+
96
+ const jsResolvers = `import { GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
97
+ import { UserType } from "./types.js";
19
98
 
20
99
  export const users = [
21
100
  { id: "1", name: "John Doe", email: "john@example.com" },
@@ -54,9 +133,10 @@ export const mutations = {
54
133
  }
55
134
  }
56
135
  };
57
- `,
58
- "schema.ts": `import { GraphQLSchema, GraphQLObjectType } from "graphql";
59
- import { queries, mutations } from "./resolvers${ext}";
136
+ `;
137
+
138
+ const tsSchema = `import { GraphQLSchema, GraphQLObjectType } from "graphql";
139
+ import { queries, mutations } from "./resolvers";
60
140
 
61
141
  const Query = new GraphQLObjectType({
62
142
  name: "Query",
@@ -69,6 +149,27 @@ const Mutation = new GraphQLObjectType({
69
149
  });
70
150
 
71
151
  export const graphqlSchema = new GraphQLSchema({ query: Query, mutation: Mutation });
72
- `
152
+ `;
153
+
154
+ const jsSchema = `import { GraphQLSchema, GraphQLObjectType } from "graphql";
155
+ import { queries, mutations } from "./resolvers.js";
156
+
157
+ const Query = new GraphQLObjectType({
158
+ name: "Query",
159
+ fields: queries
160
+ });
161
+
162
+ const Mutation = new GraphQLObjectType({
163
+ name: "Mutation",
164
+ fields: mutations
165
+ });
166
+
167
+ export const graphqlSchema = new GraphQLSchema({ query: Query, mutation: Mutation });
168
+ `;
169
+
170
+ return {
171
+ "types.ts": isTs ? tsTypes : jsTypes,
172
+ "resolvers.ts": isTs ? tsResolvers : jsResolvers,
173
+ "schema.ts": isTs ? tsSchema : jsSchema
73
174
  };
74
175
  }
@@ -16,7 +16,7 @@ export function generateJWTKeys(): JWTKeys {
16
16
 
17
17
  export function getTypeScriptPackageJson(name: string, telemetry: string, swagger: boolean, graphql: boolean) {
18
18
  const deps: Record<string, string> = {
19
- "sprint-es": "^0.0.85"
19
+ "sprint-es": "^0.0.87"
20
20
  };
21
21
 
22
22
  const devDeps: Record<string, string> = {
@@ -56,7 +56,7 @@ export function getTypeScriptPackageJson(name: string, telemetry: string, swagge
56
56
 
57
57
  export function getJavaScriptPackageJson(name: string, telemetry: string, swagger: boolean, graphql: boolean) {
58
58
  const deps: Record<string, string> = {
59
- "sprint-es": "^0.0.85"
59
+ "sprint-es": "^0.0.87"
60
60
  };
61
61
 
62
62
  if (telemetry === "sentry" || telemetry === "glitchtip") deps["@sentry/node"] = "^8.0.0";