create-openibm 0.1.1 → 0.1.3

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.
@@ -53,7 +53,7 @@ function tsconfig() {
53
53
  forceConsistentCasingInFileNames: true,
54
54
  baseUrl: '.',
55
55
  paths: {
56
- '.openibm': ['./node_modules/.openibm/index.ts'],
56
+ 'openibm': ['./node_modules/openibm/index.ts'],
57
57
  },
58
58
  },
59
59
  include: ['src'],
@@ -65,7 +65,7 @@ function indexTs(a) {
65
65
  const hasProgram = a.features.includes('program');
66
66
  const hasTable = a.features.includes('table');
67
67
  const imports = [
68
- `import { createClient } from '.openibm';`,
68
+ `import { createClient } from 'openibm';`,
69
69
  ...(a.transport === 'odbc' ? [`import 'odbc';`] : []),
70
70
  ];
71
71
  const clientConfig = clientConfigBlock(a);
@@ -82,7 +82,7 @@ function tsconfig() {
82
82
  forceConsistentCasingInFileNames: true,
83
83
  baseUrl: '.',
84
84
  paths: {
85
- '.openibm': ['./node_modules/.openibm/index.ts'],
85
+ 'openibm': ['./node_modules/openibm/index.ts'],
86
86
  },
87
87
  },
88
88
  include: ['src'],
@@ -127,12 +127,15 @@ function appTs(hasProgram, hasTable) {
127
127
  `// ── Middleware ────────────────────────────────────────────────────────────────`,
128
128
  ``,
129
129
  `app.use(express.json());`,
130
- `app.use(morgan('dev'));`,
131
130
  ``,
132
131
  `// ── API docs ──────────────────────────────────────────────────────────────────`,
133
132
  ``,
134
133
  `setupDocs(app);`,
135
134
  ``,
135
+ `// ── Middleware ────────────────────────────────────────────────────────────────`,
136
+ ``,
137
+ `app.use(morgan('dev'));`,
138
+ ``,
136
139
  `// ── Routes ───────────────────────────────────────────────────────────────────`,
137
140
  ``,
138
141
  `app.use('/', router);`,
@@ -144,7 +147,7 @@ function appTs(hasProgram, hasTable) {
144
147
  // ── src/client.ts ─────────────────────────────────────────────────────────────
145
148
  function clientTs(a) {
146
149
  return [
147
- `import { createClient } from '.openibm';`,
150
+ `import { createClient } from 'openibm';`,
148
151
  ``,
149
152
  clientConfigBlock(a),
150
153
  ``,
@@ -5,7 +5,9 @@ export function nestjsFiles(a) {
5
5
  const files = {
6
6
  'package.json': packageJson(a),
7
7
  'tsconfig.json': tsconfig(),
8
- 'nodemon.json': nodemonJson(),
8
+ 'nest-cli.json': nestCliJson(),
9
+ '.gitignore': gitignore(),
10
+ '.env.example': envExample(a),
9
11
  'src/main.ts': mainTs(a),
10
12
  'src/app.module.ts': appModuleTs(hasProgram, hasTable),
11
13
  'src/docs.ts': docsTs(a),
@@ -38,16 +40,17 @@ function packageJson(a) {
38
40
  name: a.projectName,
39
41
  version: '0.1.0',
40
42
  private: true,
41
- type: 'module',
42
43
  scripts: {
43
44
  generate: 'openibm generate',
44
- build: 'tsc --project tsconfig.json',
45
- dev: 'nodemon',
46
- start: 'node dist/main.js',
45
+ build: 'nest build',
46
+ dev: 'nest start --watch',
47
+ start: 'node dist/main',
48
+ 'start:prod': 'node dist/main',
47
49
  'link:dev': 'node scripts/link-dev.mjs',
48
50
  },
49
51
  dependencies: {
50
52
  '@nestjs/common': '^10.0.0',
53
+ '@nestjs/config': '^3.0.0',
51
54
  '@nestjs/core': '^10.0.0',
52
55
  '@nestjs/platform-express': '^10.0.0',
53
56
  '@nestjs/swagger': '^7.0.0',
@@ -63,11 +66,10 @@ function packageJson(a) {
63
66
  ...(a.transport === 'ssh' ? { ssh2: '^1.15.0' } : {}),
64
67
  },
65
68
  devDependencies: {
69
+ '@nestjs/cli': '^10.0.0',
66
70
  '@openibm/client': '^0.1.0',
67
71
  '@types/morgan': '^1.9.0',
68
72
  '@types/node': '^22.0.0',
69
- nodemon: '^3.1.0',
70
- tsx: '^4.0.0',
71
73
  typescript: '^5.7.0',
72
74
  },
73
75
  engines: { node: '>=20.0.0' },
@@ -78,8 +80,7 @@ function tsconfig() {
78
80
  return JSON.stringify({
79
81
  compilerOptions: {
80
82
  target: 'ES2022',
81
- module: 'NodeNext',
82
- moduleResolution: 'NodeNext',
83
+ module: 'CommonJS',
83
84
  outDir: './dist',
84
85
  rootDir: './src',
85
86
  strict: true,
@@ -90,19 +91,22 @@ function tsconfig() {
90
91
  forceConsistentCasingInFileNames: true,
91
92
  baseUrl: '.',
92
93
  paths: {
93
- '.openibm': ['./node_modules/.openibm/index.ts'],
94
+ 'openibm': ['./node_modules/openibm/index.ts'],
94
95
  },
95
96
  },
96
97
  include: ['src'],
97
98
  exclude: ['node_modules', 'dist'],
98
99
  }, null, 4) + '\n';
99
100
  }
100
- // ── nodemon.json ──────────────────────────────────────────────────────────────
101
- function nodemonJson() {
101
+ // ── nest-cli.json ─────────────────────────────────────────────────────────────
102
+ function nestCliJson() {
102
103
  return JSON.stringify({
103
- watch: ['src'],
104
- ext: 'ts,json',
105
- exec: 'node --env-file=.env --import tsx/esm src/main.ts',
104
+ $schema: 'https://json.schemastore.org/nest-cli',
105
+ collection: '@nestjs/schematics',
106
+ sourceRoot: 'src',
107
+ compilerOptions: {
108
+ deleteOutDir: true,
109
+ },
106
110
  }, null, 4) + '\n';
107
111
  }
108
112
  // ── src/main.ts ───────────────────────────────────────────────────────────────
@@ -113,17 +117,18 @@ function mainTs(a) {
113
117
  `import { NestFactory } from '@nestjs/core';`,
114
118
  `import { ValidationPipe } from '@nestjs/common';`,
115
119
  `import morgan from 'morgan';`,
116
- `import { AppModule } from './app.module.js';`,
117
- `import { setupDocs } from './docs.js';`,
120
+ `import { AppModule } from './app.module';`,
121
+ `import { setupDocs } from './docs';`,
118
122
  ``,
119
123
  `async function bootstrap(): Promise<void> {`,
120
124
  ` const app = await NestFactory.create(AppModule);`,
121
125
  ``,
122
- ` app.use(morgan('dev'));`,
123
126
  ` app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));`,
124
127
  ``,
125
128
  ` setupDocs(app);`,
126
129
  ``,
130
+ ` app.use(morgan('dev'));`,
131
+ ``,
127
132
  ` const port = Number(process.env.PORT ?? 3000);`,
128
133
  ` await app.listen(port);`,
129
134
  ` console.log(\`Application: http://localhost:\${port}\`);`,
@@ -139,16 +144,21 @@ function mainTs(a) {
139
144
  function appModuleTs(hasProgram, hasTable) {
140
145
  const imports = [
141
146
  `import { Module } from '@nestjs/common';`,
142
- `import { IBMiModule } from './ibmi/ibmi.module.js';`,
143
- `import { HealthModule } from './health/health.module.js';`,
147
+ `import { ConfigModule } from '@nestjs/config';`,
148
+ `import { IBMiModule } from './ibmi/ibmi.module';`,
149
+ `import { HealthModule } from './health/health.module';`,
150
+ ];
151
+ const moduleImports = [
152
+ `ConfigModule.forRoot({ isGlobal: true, envFilePath: '.env' })`,
153
+ `IBMiModule`,
154
+ `HealthModule`,
144
155
  ];
145
- const moduleImports = [`IBMiModule`, `HealthModule`];
146
156
  if (hasTable) {
147
- imports.push(`import { CustomersModule } from './customers/customers.module.js';`);
157
+ imports.push(`import { CustomersModule } from './customers/customers.module';`);
148
158
  moduleImports.push(`CustomersModule`);
149
159
  }
150
160
  if (hasProgram) {
151
- imports.push(`import { ProgramsModule } from './programs/programs.module.js';`);
161
+ imports.push(`import { ProgramsModule } from './programs/programs.module';`);
152
162
  moduleImports.push(`ProgramsModule`);
153
163
  }
154
164
  return [
@@ -191,7 +201,7 @@ function docsTs(a) {
191
201
  function ibmiModuleTs() {
192
202
  return [
193
203
  `import { Global, Module } from '@nestjs/common';`,
194
- `import { IBMiService } from './ibmi.service.js';`,
204
+ `import { IBMiService } from './ibmi.service';`,
195
205
  ``,
196
206
  `@Global()`,
197
207
  `@Module({`,
@@ -221,7 +231,7 @@ function ibmiServiceTs(a) {
221
231
  const extras = [httpOptions, sshOptions, odbcOptions].filter(Boolean).join('\n');
222
232
  return [
223
233
  `import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';`,
224
- `import { createClient } from '.openibm';`,
234
+ `import { createClient } from 'openibm';`,
225
235
  ``,
226
236
  `@Injectable()`,
227
237
  `export class IBMiService implements OnModuleInit, OnModuleDestroy {`,
@@ -243,7 +253,7 @@ function ibmiServiceTs(a) {
243
253
  function healthModuleTs() {
244
254
  return [
245
255
  `import { Module } from '@nestjs/common';`,
246
- `import { HealthController } from './health.controller.js';`,
256
+ `import { HealthController } from './health.controller';`,
247
257
  ``,
248
258
  `@Module({ controllers: [HealthController] })`,
249
259
  `export class HealthModule {}`,
@@ -255,7 +265,7 @@ function healthControllerTs() {
255
265
  return [
256
266
  `import { Controller, Get } from '@nestjs/common';`,
257
267
  `import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';`,
258
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
268
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
259
269
  ``,
260
270
  `@ApiTags('Health')`,
261
271
  `@Controller('health')`,
@@ -276,8 +286,8 @@ function healthControllerTs() {
276
286
  function customersModuleTs() {
277
287
  return [
278
288
  `import { Module } from '@nestjs/common';`,
279
- `import { CustomersController } from './customers.controller.js';`,
280
- `import { CustomersService } from './customers.service.js';`,
289
+ `import { CustomersController } from './customers.controller';`,
290
+ `import { CustomersService } from './customers.service';`,
281
291
  ``,
282
292
  `@Module({`,
283
293
  ` controllers: [CustomersController],`,
@@ -291,7 +301,7 @@ function customersModuleTs() {
291
301
  function customersServiceTs() {
292
302
  return [
293
303
  `import { Injectable } from '@nestjs/common';`,
294
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
304
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
295
305
  ``,
296
306
  `@Injectable()`,
297
307
  `export class CustomersService {`,
@@ -319,7 +329,7 @@ function customersControllerTs() {
319
329
  return [
320
330
  `import { Controller, Get, Param, Query, NotFoundException } from '@nestjs/common';`,
321
331
  `import { ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';`,
322
- `import { CustomersService } from './customers.service.js';`,
332
+ `import { CustomersService } from './customers.service';`,
323
333
  ``,
324
334
  `@ApiTags('Customers')`,
325
335
  `@Controller('customers')`,
@@ -352,8 +362,8 @@ function customersControllerTs() {
352
362
  function programsModuleTs() {
353
363
  return [
354
364
  `import { Module } from '@nestjs/common';`,
355
- `import { ProgramsController } from './programs.controller.js';`,
356
- `import { ProgramsService } from './programs.service.js';`,
365
+ `import { ProgramsController } from './programs.controller';`,
366
+ `import { ProgramsService } from './programs.service';`,
357
367
  ``,
358
368
  `@Module({`,
359
369
  ` controllers: [ProgramsController],`,
@@ -367,7 +377,7 @@ function programsModuleTs() {
367
377
  function programsServiceTs() {
368
378
  return [
369
379
  `import { Injectable } from '@nestjs/common';`,
370
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
380
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
371
381
  ``,
372
382
  `@Injectable()`,
373
383
  `export class ProgramsService {`,
@@ -385,8 +395,8 @@ function programsControllerTs() {
385
395
  return [
386
396
  `import { Controller, Post, Body } from '@nestjs/common';`,
387
397
  `import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';`,
388
- `import { ProgramsService } from './programs.service.js';`,
389
- `import { CalculateDto } from './dto/calculate.dto.js';`,
398
+ `import { ProgramsService } from './programs.service';`,
399
+ `import { CalculateDto } from './dto/calculate.dto';`,
390
400
  ``,
391
401
  `@ApiTags('Programs')`,
392
402
  `@Controller('programs')`,
@@ -410,7 +420,7 @@ function calculateDtoTs() {
410
420
  return [
411
421
  `import { IsNumber } from 'class-validator';`,
412
422
  `import { ApiProperty } from '@nestjs/swagger';`,
413
- `import { IbmiInt } from '../../common/ibmi-validators.js';`,
423
+ `import { IbmiInt } from '../../common/ibmi-validators';`,
414
424
  ``,
415
425
  `export class CalculateDto {`,
416
426
  ` @ApiProperty({ example: 5, description: 'Input integer (IBM i INTEGER: -2147483648 to 2147483647)' })`,
@@ -585,6 +595,33 @@ function ibmiValidatorsNestTs() {
585
595
  ``,
586
596
  ].join('\n');
587
597
  }
598
+ // ── .gitignore ────────────────────────────────────────────────────────────────
599
+ function gitignore() {
600
+ return [
601
+ `node_modules`,
602
+ `dist`,
603
+ `.env`,
604
+ `*.js.map`,
605
+ ``,
606
+ ].join('\n');
607
+ }
608
+ // ── .env.example ──────────────────────────────────────────────────────────────
609
+ function envExample(a) {
610
+ const defaultPort = a.transport === 'ssh' ? '22' : a.transport === 'https' ? '47700' : '57700';
611
+ return [
612
+ `# IBM i connection — copy to .env and fill in your values`,
613
+ `IBMI_TRANSPORT=${a.transport}`,
614
+ `IBMI_SYSTEM=my-ibmi.example.com`,
615
+ `IBMI_USER=`,
616
+ `IBMI_PASS=`,
617
+ ...(a.transport === 'http' || a.transport === 'https'
618
+ ? [`IBMI_PORT=${defaultPort}`, `IBMI_DATABASE=*LOCAL`]
619
+ : []),
620
+ ...(a.transport === 'ssh' ? [`IBMI_SSH_PORT=${defaultPort}`] : []),
621
+ `PORT=3000`,
622
+ ``,
623
+ ].join('\n');
624
+ }
588
625
  // ── .vscode/settings.json ─────────────────────────────────────────────────────
589
626
  function vscodeSettings() {
590
627
  return JSON.stringify({
@@ -737,7 +774,7 @@ function readme(a, hasProgram, hasTable) {
737
774
  `## Development`,
738
775
  ``,
739
776
  `\`\`\`bash`,
740
- `npm run dev # starts with nodemon — restarts on file save`,
777
+ `npm run dev # nest start --watchrebuilds and restarts on file save`,
741
778
  `\`\`\``,
742
779
  ``,
743
780
  `## Endpoints`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-openibm",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Create a new IBM i application — interactive scaffold with Express, NestJS, or plain Node.js",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/satyamlohiya/openibm",