@stravigor/create 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/index.ts +7 -5
- package/src/prompts.ts +2 -2
- package/src/templates/shared.ts +53 -41
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -99,22 +99,24 @@ async function main(): Promise<void> {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (!/^[a-zA-Z0-9_-]+$/.test(projectName)) {
|
|
102
|
-
console.error(
|
|
102
|
+
console.error(
|
|
103
|
+
red(` Invalid project name. Use only letters, numbers, hyphens, and underscores.`)
|
|
104
|
+
)
|
|
103
105
|
process.exit(1)
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
// Template
|
|
107
109
|
let template = args.template
|
|
108
110
|
if (!template) {
|
|
109
|
-
template = await select('Which template?', [
|
|
111
|
+
template = (await select('Which template?', [
|
|
110
112
|
{ label: 'api', value: 'api', description: 'Headless REST API' },
|
|
111
113
|
{ label: 'web', value: 'web', description: 'Full-stack with views and static files' },
|
|
112
|
-
]) as 'api' | 'web'
|
|
114
|
+
])) as 'api' | 'web'
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
// Database name
|
|
116
118
|
const defaultDb = toSnakeCase(projectName)
|
|
117
|
-
const dbName = args.db ?? await input('Database name:', defaultDb)
|
|
119
|
+
const dbName = args.db ?? (await input('Database name:', defaultDb))
|
|
118
120
|
|
|
119
121
|
console.log()
|
|
120
122
|
|
|
@@ -150,7 +152,7 @@ async function main(): Promise<void> {
|
|
|
150
152
|
console.log()
|
|
151
153
|
}
|
|
152
154
|
|
|
153
|
-
main().catch(
|
|
155
|
+
main().catch(err => {
|
|
154
156
|
console.error(red(` Error: ${err instanceof Error ? err.message : err}`))
|
|
155
157
|
process.exit(1)
|
|
156
158
|
})
|
package/src/prompts.ts
CHANGED
|
@@ -30,7 +30,7 @@ export async function select(message: string, choices: Choice[]): Promise<string
|
|
|
30
30
|
}
|
|
31
31
|
render()
|
|
32
32
|
|
|
33
|
-
return new Promise(
|
|
33
|
+
return new Promise(resolve => {
|
|
34
34
|
const stdin = process.stdin
|
|
35
35
|
stdin.setRawMode(true)
|
|
36
36
|
stdin.resume()
|
|
@@ -84,7 +84,7 @@ export async function select(message: string, choices: Choice[]): Promise<string
|
|
|
84
84
|
export async function input(message: string, defaultValue: string): Promise<string> {
|
|
85
85
|
process.stdout.write(` \x1b[1m${message}\x1b[0m \x1b[2m(${defaultValue})\x1b[0m `)
|
|
86
86
|
|
|
87
|
-
return new Promise(
|
|
87
|
+
return new Promise(resolve => {
|
|
88
88
|
const stdin = process.stdin
|
|
89
89
|
stdin.setRawMode(true)
|
|
90
90
|
stdin.resume()
|
package/src/templates/shared.ts
CHANGED
|
@@ -27,50 +27,62 @@ export function getSharedFiles(opts: ScaffoldOptions): TemplateFile[] {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function packageJson(opts: ScaffoldOptions): string {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
return (
|
|
31
|
+
JSON.stringify(
|
|
32
|
+
{
|
|
33
|
+
name: opts.projectName,
|
|
34
|
+
version: '0.0.1',
|
|
35
|
+
type: 'module',
|
|
36
|
+
private: true,
|
|
37
|
+
scripts: {
|
|
38
|
+
dev: 'bun --hot index.ts',
|
|
39
|
+
start: 'bun index.ts',
|
|
40
|
+
test: 'bun test tests/',
|
|
41
|
+
},
|
|
42
|
+
dependencies: {
|
|
43
|
+
'@stravigor/core': '^0.1.0',
|
|
44
|
+
luxon: '^3.7.2',
|
|
45
|
+
'reflect-metadata': '^0.2.2',
|
|
46
|
+
},
|
|
47
|
+
devDependencies: {
|
|
48
|
+
'@types/bun': 'latest',
|
|
49
|
+
'@types/luxon': '^3.7.1',
|
|
50
|
+
'@stravigor/testing': '^0.1.0',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
null,
|
|
54
|
+
2
|
|
55
|
+
) + '\n'
|
|
56
|
+
)
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
function tsconfig(): string {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
return (
|
|
61
|
+
JSON.stringify(
|
|
62
|
+
{
|
|
63
|
+
compilerOptions: {
|
|
64
|
+
lib: ['ESNext'],
|
|
65
|
+
target: 'ESNext',
|
|
66
|
+
module: 'ESNext',
|
|
67
|
+
moduleDetection: 'force',
|
|
68
|
+
allowJs: true,
|
|
69
|
+
moduleResolution: 'bundler',
|
|
70
|
+
allowImportingTsExtensions: true,
|
|
71
|
+
noEmit: true,
|
|
72
|
+
experimentalDecorators: true,
|
|
73
|
+
emitDecoratorMetadata: true,
|
|
74
|
+
strict: true,
|
|
75
|
+
skipLibCheck: true,
|
|
76
|
+
noFallthroughCasesInSwitch: true,
|
|
77
|
+
noUnusedLocals: false,
|
|
78
|
+
noUnusedParameters: false,
|
|
79
|
+
},
|
|
80
|
+
include: ['**/*.ts'],
|
|
81
|
+
},
|
|
82
|
+
null,
|
|
83
|
+
2
|
|
84
|
+
) + '\n'
|
|
85
|
+
)
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
function dotEnv(opts: ScaffoldOptions, appKey: string): string {
|