create-sprint 0.0.108 → 0.0.110
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 +12 -8
- package/dist/templates/configFiles.js +29 -47
- package/dist/templates/docker.js +13 -2
- package/dist/templates/graphql.js +0 -1
- package/dist/templates/index.js +2 -2
- package/dist/templates/packageJson.js +22 -7
- package/dist/templates/routes.js +0 -1
- package/package.json +3 -2
- package/src/templates/configFiles.ts +16 -40
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { join } from "path";
|
|
|
5
5
|
import color from "picocolors";
|
|
6
6
|
import * as p from "@clack/prompts";
|
|
7
7
|
import { validateProjectName } from "./validators.js";
|
|
8
|
-
import { getTypeScriptPackageJson, getJavaScriptPackageJson, getTsConfig,
|
|
8
|
+
import { getTypeScriptPackageJson, getJavaScriptPackageJson, getTsConfig, getMainFile, getHomeRoute, getAdminRoute, getHomeController, getAdminController, getEnvExample, getInternalAuthMiddleware, getUserAuthMiddleware, getHomeSchema, getAdminSchema, getDockerfile, getDockerCompose, getGitignore, getDockerIgnore, getSprintConfigFile, getEnvDevelopment, getEnvProduction, getExampleCronJob, getGraphQLFiles } from "./generators.js";
|
|
9
9
|
export async function writeFile(path, content, options) {
|
|
10
10
|
if (typeof content === "string")
|
|
11
11
|
content = content.trimEnd();
|
|
@@ -21,7 +21,7 @@ export async function runCLI(args) {
|
|
|
21
21
|
config = {
|
|
22
22
|
projectName: options.projectName || "sprint-app",
|
|
23
23
|
language: options.language || "typescript",
|
|
24
|
-
telemetry: options.telemetry
|
|
24
|
+
telemetry: options.telemetry ?? "none",
|
|
25
25
|
swagger: options.swagger ?? true,
|
|
26
26
|
graphql: options.graphql ?? false,
|
|
27
27
|
docker: options.docker || false,
|
|
@@ -32,7 +32,7 @@ export async function runCLI(args) {
|
|
|
32
32
|
projectName: () => p.text({
|
|
33
33
|
message: "Project name:",
|
|
34
34
|
placeholder: "my-api",
|
|
35
|
-
validate: (v) => validateProjectName(v) || undefined,
|
|
35
|
+
validate: (v) => validateProjectName(v || "sprint-app") || undefined,
|
|
36
36
|
}),
|
|
37
37
|
language: () => p.select({
|
|
38
38
|
message: "Language:",
|
|
@@ -125,8 +125,11 @@ function parseArgs(args) {
|
|
|
125
125
|
}
|
|
126
126
|
else
|
|
127
127
|
options.language = "typescript";
|
|
128
|
-
if (hasName !== -1
|
|
129
|
-
|
|
128
|
+
if (hasName !== -1) {
|
|
129
|
+
const value = args[hasName + 1];
|
|
130
|
+
if (typeof value === "string")
|
|
131
|
+
options.projectName = value;
|
|
132
|
+
}
|
|
130
133
|
if (args.includes("--current"))
|
|
131
134
|
options.projectName = ".";
|
|
132
135
|
if (args.includes("--docker"))
|
|
@@ -141,8 +144,10 @@ function parseArgs(args) {
|
|
|
141
144
|
options.graphql = false;
|
|
142
145
|
if (args.includes("--no-install"))
|
|
143
146
|
options.skipInstall = true;
|
|
144
|
-
if (telemetryArg && ["sentry", "glitchtip", "discord", "none"].includes(telemetryArg))
|
|
145
|
-
|
|
147
|
+
if (telemetryArg && ["sentry", "glitchtip", "discord", "none"].includes(telemetryArg)) {
|
|
148
|
+
if (typeof telemetryArg === "string" && ["sentry", "glitchtip", "discord", "none"].includes(telemetryArg))
|
|
149
|
+
options.telemetry = telemetryArg;
|
|
150
|
+
}
|
|
146
151
|
return options;
|
|
147
152
|
}
|
|
148
153
|
;
|
|
@@ -163,7 +168,6 @@ async function createProject(projectName, language, telemetry, swagger, graphql,
|
|
|
163
168
|
await writeFile(join(targetDir, "package.json"), JSON.stringify(pkgJson, null, 2));
|
|
164
169
|
if (language === "typescript") {
|
|
165
170
|
await writeFile(join(targetDir, "tsconfig.json"), getTsConfig());
|
|
166
|
-
await writeFile(join(targetDir, "vite.config.ts"), getViteConfig());
|
|
167
171
|
await writeFile(join(targetDir, "sprint.config.ts"), getSprintConfigFile(language, telemetry, swagger, graphql));
|
|
168
172
|
}
|
|
169
173
|
else
|
|
@@ -1,52 +1,34 @@
|
|
|
1
1
|
export function getTsConfig() {
|
|
2
|
-
return
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
esModuleInterop: true,
|
|
13
|
-
skipLibCheck: true,
|
|
14
|
-
forceConsistentCasingInFileNames: true,
|
|
15
|
-
resolveJsonModule: true,
|
|
16
|
-
declaration: true,
|
|
17
|
-
declarationMap: true,
|
|
18
|
-
sourceMap: true,
|
|
19
|
-
baseUrl: ".",
|
|
20
|
-
paths: {
|
|
21
|
-
"@/*": ["./src/*"]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
include: ["src/**/*"],
|
|
25
|
-
exclude: ["node_modules", "dist"],
|
|
26
|
-
}, null, 2);
|
|
27
|
-
}
|
|
28
|
-
;
|
|
29
|
-
export function getViteConfig() {
|
|
30
|
-
return `import { defineConfig } from "vite";
|
|
31
|
-
import { resolve } from "path";
|
|
32
|
-
|
|
33
|
-
export default defineConfig({
|
|
34
|
-
build: {
|
|
35
|
-
outDir: "dist",
|
|
36
|
-
emptyOutDir: true,
|
|
37
|
-
rollupOptions: {
|
|
38
|
-
input: resolve(__dirname, "src/app.ts"),
|
|
39
|
-
external: ["sprint-es", "express", "cors", "morgan", "serve-favicon", "dotenv", "graphql", "graphql-http", "ruru"]
|
|
40
|
-
},
|
|
41
|
-
target: "ES2020"
|
|
2
|
+
return `
|
|
3
|
+
{
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"baseUrl": "./src",
|
|
8
|
+
"paths": {
|
|
9
|
+
"@/*": [
|
|
10
|
+
"*"
|
|
11
|
+
]
|
|
42
12
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
13
|
+
"moduleResolution": "Node",
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
"importsNotUsedAsValues": "remove",
|
|
16
|
+
"strict": true,
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"types": [
|
|
21
|
+
"vitest/globals"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"include": [
|
|
25
|
+
"src/**/*"
|
|
26
|
+
],
|
|
27
|
+
"exclude": [
|
|
28
|
+
"node_modules"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
50
32
|
}
|
|
51
33
|
;
|
|
52
34
|
export function getSprintConfigFile(language, telemetry, swagger, graphql) {
|
package/dist/templates/docker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function getDockerfile(language) {
|
|
2
2
|
if (language === "typescript") {
|
|
3
|
-
return `FROM node:20-alpine
|
|
3
|
+
return `FROM node:20-alpine AS builder
|
|
4
4
|
|
|
5
5
|
WORKDIR /app
|
|
6
6
|
|
|
@@ -12,6 +12,17 @@ COPY . .
|
|
|
12
12
|
|
|
13
13
|
RUN npm run build
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
FROM node:20-alpine
|
|
17
|
+
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
|
|
20
|
+
COPY package*.json ./
|
|
21
|
+
|
|
22
|
+
RUN npm ci --omit=dev
|
|
23
|
+
|
|
24
|
+
COPY --from=builder /app/dist ./dist
|
|
25
|
+
|
|
15
26
|
EXPOSE 5000
|
|
16
27
|
|
|
17
28
|
CMD ["npm", "start"]
|
|
@@ -33,7 +44,7 @@ CMD ["npm", "start"]
|
|
|
33
44
|
`;
|
|
34
45
|
}
|
|
35
46
|
;
|
|
36
|
-
export function getDockerCompose(
|
|
47
|
+
export function getDockerCompose(_language) {
|
|
37
48
|
return `
|
|
38
49
|
services:
|
|
39
50
|
app:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export function getGraphQLFiles(language) {
|
|
2
2
|
const isTs = language === "typescript";
|
|
3
|
-
const ext = isTs ? "" : ".js";
|
|
4
3
|
const tsTypes = `import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLNonNull } from "graphql";
|
|
5
4
|
|
|
6
5
|
export const UserType = new GraphQLObjectType({
|
package/dist/templates/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Package JSON
|
|
2
2
|
export { generateJWTKeys, getTypeScriptPackageJson, getJavaScriptPackageJson } from "./packageJson.js";
|
|
3
|
-
// Config Files (tsconfig,
|
|
4
|
-
export { getTsConfig,
|
|
3
|
+
// Config Files (tsconfig, sprint.config)
|
|
4
|
+
export { getTsConfig, getSprintConfigFile } from "./configFiles.js";
|
|
5
5
|
// Environment Files
|
|
6
6
|
export { getEnvExample, getEnvDevelopment, getEnvProduction } from "./env.js";
|
|
7
7
|
// Routes
|
|
@@ -10,14 +10,13 @@ export function generateJWTKeys() {
|
|
|
10
10
|
;
|
|
11
11
|
export function getTypeScriptPackageJson(name, telemetry, swagger, graphql) {
|
|
12
12
|
const deps = {
|
|
13
|
-
"sprint-es": "^0.0.
|
|
13
|
+
"sprint-es": "^0.0.135"
|
|
14
14
|
};
|
|
15
15
|
const devDeps = {
|
|
16
16
|
"@types/node": "^22.0.0",
|
|
17
17
|
"tsx": "^4.19.0",
|
|
18
18
|
typescript: "^5.6.0",
|
|
19
|
-
|
|
20
|
-
"vite-plugin-dts": "^4.5.4"
|
|
19
|
+
tsup: "^8.5.1"
|
|
21
20
|
};
|
|
22
21
|
if (telemetry === "sentry" || telemetry === "glitchtip")
|
|
23
22
|
deps["@sentry/node"] = "^8.0.0";
|
|
@@ -36,7 +35,8 @@ export function getTypeScriptPackageJson(name, telemetry, swagger, graphql) {
|
|
|
36
35
|
name: name === "." ? "sprint-app" : name,
|
|
37
36
|
version: "0.0.1",
|
|
38
37
|
description: "Sprint API",
|
|
39
|
-
main: "dist/
|
|
38
|
+
main: "dist/app.js",
|
|
39
|
+
type: "module",
|
|
40
40
|
scripts: {
|
|
41
41
|
build: "sprint-es build",
|
|
42
42
|
start: "sprint-es start",
|
|
@@ -45,13 +45,28 @@ export function getTypeScriptPackageJson(name, telemetry, swagger, graphql) {
|
|
|
45
45
|
"generate:keys": "sprint-es generate-keys"
|
|
46
46
|
},
|
|
47
47
|
dependencies: deps,
|
|
48
|
-
devDependencies: devDeps
|
|
48
|
+
devDependencies: devDeps,
|
|
49
|
+
tsup: {
|
|
50
|
+
entry: [
|
|
51
|
+
"src/**/*.ts"
|
|
52
|
+
],
|
|
53
|
+
outDir: "dist",
|
|
54
|
+
format: [
|
|
55
|
+
"esm"
|
|
56
|
+
],
|
|
57
|
+
target: "es2020",
|
|
58
|
+
sourcemap: true,
|
|
59
|
+
clean: true,
|
|
60
|
+
dts: true,
|
|
61
|
+
splitting: false,
|
|
62
|
+
skipNodeModulesBundle: true
|
|
63
|
+
}
|
|
49
64
|
};
|
|
50
65
|
}
|
|
51
66
|
;
|
|
52
67
|
export function getJavaScriptPackageJson(name, telemetry, swagger, graphql) {
|
|
53
68
|
const deps = {
|
|
54
|
-
"sprint-es": "^0.0.
|
|
69
|
+
"sprint-es": "^0.0.135"
|
|
55
70
|
};
|
|
56
71
|
if (telemetry === "sentry" || telemetry === "glitchtip")
|
|
57
72
|
deps["@sentry/node"] = "^8.0.0";
|
|
@@ -68,7 +83,7 @@ export function getJavaScriptPackageJson(name, telemetry, swagger, graphql) {
|
|
|
68
83
|
name: name === "." ? "sprint-app" : name,
|
|
69
84
|
version: "0.0.1",
|
|
70
85
|
description: "Sprint API",
|
|
71
|
-
main: "src/
|
|
86
|
+
main: "src/app.js",
|
|
72
87
|
type: "module",
|
|
73
88
|
scripts: {
|
|
74
89
|
build: "sprint-es build",
|
package/dist/templates/routes.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sprint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.110",
|
|
4
4
|
"description": "Create a new Sprint API project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"src/**/*"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc && node -e \"const fs=require('fs');const p='dist/cli.js';let c=fs.readFileSync(p,'utf8');if(!c.startsWith('#!')){fs.writeFileSync(p,'#!/usr/bin/env node\\n'+c)}\"",
|
|
15
|
+
"build": "rimraf dist && tsc && node -e \"const fs=require('fs');const p='dist/cli.js';let c=fs.readFileSync(p,'utf8');if(!c.startsWith('#!')){fs.writeFileSync(p,'#!/usr/bin/env node\\n'+c)}\"",
|
|
16
16
|
"prepublishOnly": "npm version patch && npm run build",
|
|
17
17
|
"start": "node dist/cli.js"
|
|
18
18
|
},
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.3.3",
|
|
33
|
+
"rimraf": "^6.0.0",
|
|
33
34
|
"tsx": "^4.19.0",
|
|
34
35
|
"typescript": "^5.9.3"
|
|
35
36
|
},
|
|
@@ -2,54 +2,30 @@ export function getTsConfig() {
|
|
|
2
2
|
return `
|
|
3
3
|
{
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"module": "NodeNext",
|
|
9
|
-
"moduleResolution": "NodeNext",
|
|
10
|
-
"lib": [
|
|
11
|
-
"ES2022"
|
|
12
|
-
],
|
|
13
|
-
"types": [
|
|
14
|
-
"node"
|
|
15
|
-
],
|
|
16
|
-
/* Output */
|
|
17
|
-
"outDir": "./dist",
|
|
18
|
-
"rootDir": "./src",
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"declarationMap": true,
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
/* Strict */
|
|
23
|
-
"strict": true,
|
|
24
|
-
"noUncheckedIndexedAccess": true,
|
|
25
|
-
"noImplicitOverride": true,
|
|
26
|
-
"noUnusedLocals": true,
|
|
27
|
-
"noUnusedParameters": true,
|
|
28
|
-
"exactOptionalPropertyTypes": true,
|
|
29
|
-
"noFallthroughCasesInSwitch": true,
|
|
30
|
-
/* Interop */
|
|
31
|
-
"esModuleInterop": true,
|
|
32
|
-
"forceConsistentCasingInFileNames": true,
|
|
33
|
-
"resolveJsonModule": true,
|
|
34
|
-
"isolatedModules": true,
|
|
35
|
-
/* Performance */
|
|
36
|
-
"incremental": true,
|
|
37
|
-
"skipLibCheck": true,
|
|
38
|
-
"baseUrl": ".",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"baseUrl": "./src",
|
|
39
8
|
"paths": {
|
|
40
9
|
"@/*": [
|
|
41
|
-
"
|
|
10
|
+
"*"
|
|
42
11
|
]
|
|
43
|
-
}
|
|
12
|
+
},
|
|
13
|
+
"moduleResolution": "Node",
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
"importsNotUsedAsValues": "remove",
|
|
16
|
+
"strict": true,
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"types": [
|
|
21
|
+
"vitest/globals"
|
|
22
|
+
]
|
|
44
23
|
},
|
|
45
24
|
"include": [
|
|
46
25
|
"src/**/*"
|
|
47
26
|
],
|
|
48
27
|
"exclude": [
|
|
49
|
-
"node_modules"
|
|
50
|
-
"dist",
|
|
51
|
-
"**/*.test.ts",
|
|
52
|
-
"**/*.spec.ts"
|
|
28
|
+
"node_modules"
|
|
53
29
|
]
|
|
54
30
|
}
|
|
55
31
|
`;
|