@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stravigor/create",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Scaffold a new Strav application",
6
6
  "license": "MIT",
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(red(` Invalid project name. Use only letters, numbers, hyphens, and underscores.`))
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((err) => {
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((resolve) => {
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((resolve) => {
87
+ return new Promise(resolve => {
88
88
  const stdin = process.stdin
89
89
  stdin.setRawMode(true)
90
90
  stdin.resume()
@@ -27,50 +27,62 @@ export function getSharedFiles(opts: ScaffoldOptions): TemplateFile[] {
27
27
  }
28
28
 
29
29
  function packageJson(opts: ScaffoldOptions): string {
30
- return JSON.stringify({
31
- name: opts.projectName,
32
- version: '0.0.1',
33
- type: 'module',
34
- private: true,
35
- scripts: {
36
- dev: 'bun --hot index.ts',
37
- start: 'bun index.ts',
38
- test: 'bun test tests/',
39
- },
40
- dependencies: {
41
- '@stravigor/core': '^0.1.0',
42
- 'luxon': '^3.7.2',
43
- 'reflect-metadata': '^0.2.2',
44
- },
45
- devDependencies: {
46
- '@types/bun': 'latest',
47
- '@types/luxon': '^3.7.1',
48
- '@stravigor/testing': '^0.1.0',
49
- },
50
- }, null, 2) + '\n'
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 JSON.stringify({
55
- compilerOptions: {
56
- lib: ['ESNext'],
57
- target: 'ESNext',
58
- module: 'ESNext',
59
- moduleDetection: 'force',
60
- allowJs: true,
61
- moduleResolution: 'bundler',
62
- allowImportingTsExtensions: true,
63
- noEmit: true,
64
- experimentalDecorators: true,
65
- emitDecoratorMetadata: true,
66
- strict: true,
67
- skipLibCheck: true,
68
- noFallthroughCasesInSwitch: true,
69
- noUnusedLocals: false,
70
- noUnusedParameters: false,
71
- },
72
- include: ['**/*.ts'],
73
- }, null, 2) + '\n'
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 {