create-openibm 0.1.1 → 0.1.2

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'],
@@ -144,7 +144,7 @@ function appTs(hasProgram, hasTable) {
144
144
  // ── src/client.ts ─────────────────────────────────────────────────────────────
145
145
  function clientTs(a) {
146
146
  return [
147
- `import { createClient } from '.openibm';`,
147
+ `import { createClient } from 'openibm';`,
148
148
  ``,
149
149
  clientConfigBlock(a),
150
150
  ``,
@@ -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,8 +117,8 @@ 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);`,
@@ -139,16 +143,21 @@ function mainTs(a) {
139
143
  function appModuleTs(hasProgram, hasTable) {
140
144
  const imports = [
141
145
  `import { Module } from '@nestjs/common';`,
142
- `import { IBMiModule } from './ibmi/ibmi.module.js';`,
143
- `import { HealthModule } from './health/health.module.js';`,
146
+ `import { ConfigModule } from '@nestjs/config';`,
147
+ `import { IBMiModule } from './ibmi/ibmi.module';`,
148
+ `import { HealthModule } from './health/health.module';`,
149
+ ];
150
+ const moduleImports = [
151
+ `ConfigModule.forRoot({ isGlobal: true, envFilePath: '.env' })`,
152
+ `IBMiModule`,
153
+ `HealthModule`,
144
154
  ];
145
- const moduleImports = [`IBMiModule`, `HealthModule`];
146
155
  if (hasTable) {
147
- imports.push(`import { CustomersModule } from './customers/customers.module.js';`);
156
+ imports.push(`import { CustomersModule } from './customers/customers.module';`);
148
157
  moduleImports.push(`CustomersModule`);
149
158
  }
150
159
  if (hasProgram) {
151
- imports.push(`import { ProgramsModule } from './programs/programs.module.js';`);
160
+ imports.push(`import { ProgramsModule } from './programs/programs.module';`);
152
161
  moduleImports.push(`ProgramsModule`);
153
162
  }
154
163
  return [
@@ -191,7 +200,7 @@ function docsTs(a) {
191
200
  function ibmiModuleTs() {
192
201
  return [
193
202
  `import { Global, Module } from '@nestjs/common';`,
194
- `import { IBMiService } from './ibmi.service.js';`,
203
+ `import { IBMiService } from './ibmi.service';`,
195
204
  ``,
196
205
  `@Global()`,
197
206
  `@Module({`,
@@ -221,7 +230,7 @@ function ibmiServiceTs(a) {
221
230
  const extras = [httpOptions, sshOptions, odbcOptions].filter(Boolean).join('\n');
222
231
  return [
223
232
  `import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';`,
224
- `import { createClient } from '.openibm';`,
233
+ `import { createClient } from 'openibm';`,
225
234
  ``,
226
235
  `@Injectable()`,
227
236
  `export class IBMiService implements OnModuleInit, OnModuleDestroy {`,
@@ -243,7 +252,7 @@ function ibmiServiceTs(a) {
243
252
  function healthModuleTs() {
244
253
  return [
245
254
  `import { Module } from '@nestjs/common';`,
246
- `import { HealthController } from './health.controller.js';`,
255
+ `import { HealthController } from './health.controller';`,
247
256
  ``,
248
257
  `@Module({ controllers: [HealthController] })`,
249
258
  `export class HealthModule {}`,
@@ -255,7 +264,7 @@ function healthControllerTs() {
255
264
  return [
256
265
  `import { Controller, Get } from '@nestjs/common';`,
257
266
  `import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';`,
258
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
267
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
259
268
  ``,
260
269
  `@ApiTags('Health')`,
261
270
  `@Controller('health')`,
@@ -276,8 +285,8 @@ function healthControllerTs() {
276
285
  function customersModuleTs() {
277
286
  return [
278
287
  `import { Module } from '@nestjs/common';`,
279
- `import { CustomersController } from './customers.controller.js';`,
280
- `import { CustomersService } from './customers.service.js';`,
288
+ `import { CustomersController } from './customers.controller';`,
289
+ `import { CustomersService } from './customers.service';`,
281
290
  ``,
282
291
  `@Module({`,
283
292
  ` controllers: [CustomersController],`,
@@ -291,7 +300,7 @@ function customersModuleTs() {
291
300
  function customersServiceTs() {
292
301
  return [
293
302
  `import { Injectable } from '@nestjs/common';`,
294
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
303
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
295
304
  ``,
296
305
  `@Injectable()`,
297
306
  `export class CustomersService {`,
@@ -319,7 +328,7 @@ function customersControllerTs() {
319
328
  return [
320
329
  `import { Controller, Get, Param, Query, NotFoundException } from '@nestjs/common';`,
321
330
  `import { ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';`,
322
- `import { CustomersService } from './customers.service.js';`,
331
+ `import { CustomersService } from './customers.service';`,
323
332
  ``,
324
333
  `@ApiTags('Customers')`,
325
334
  `@Controller('customers')`,
@@ -352,8 +361,8 @@ function customersControllerTs() {
352
361
  function programsModuleTs() {
353
362
  return [
354
363
  `import { Module } from '@nestjs/common';`,
355
- `import { ProgramsController } from './programs.controller.js';`,
356
- `import { ProgramsService } from './programs.service.js';`,
364
+ `import { ProgramsController } from './programs.controller';`,
365
+ `import { ProgramsService } from './programs.service';`,
357
366
  ``,
358
367
  `@Module({`,
359
368
  ` controllers: [ProgramsController],`,
@@ -367,7 +376,7 @@ function programsModuleTs() {
367
376
  function programsServiceTs() {
368
377
  return [
369
378
  `import { Injectable } from '@nestjs/common';`,
370
- `import { IBMiService } from '../ibmi/ibmi.service.js';`,
379
+ `import { IBMiService } from '../ibmi/ibmi.service';`,
371
380
  ``,
372
381
  `@Injectable()`,
373
382
  `export class ProgramsService {`,
@@ -385,8 +394,8 @@ function programsControllerTs() {
385
394
  return [
386
395
  `import { Controller, Post, Body } from '@nestjs/common';`,
387
396
  `import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';`,
388
- `import { ProgramsService } from './programs.service.js';`,
389
- `import { CalculateDto } from './dto/calculate.dto.js';`,
397
+ `import { ProgramsService } from './programs.service';`,
398
+ `import { CalculateDto } from './dto/calculate.dto';`,
390
399
  ``,
391
400
  `@ApiTags('Programs')`,
392
401
  `@Controller('programs')`,
@@ -410,7 +419,7 @@ function calculateDtoTs() {
410
419
  return [
411
420
  `import { IsNumber } from 'class-validator';`,
412
421
  `import { ApiProperty } from '@nestjs/swagger';`,
413
- `import { IbmiInt } from '../../common/ibmi-validators.js';`,
422
+ `import { IbmiInt } from '../../common/ibmi-validators';`,
414
423
  ``,
415
424
  `export class CalculateDto {`,
416
425
  ` @ApiProperty({ example: 5, description: 'Input integer (IBM i INTEGER: -2147483648 to 2147483647)' })`,
@@ -585,6 +594,33 @@ function ibmiValidatorsNestTs() {
585
594
  ``,
586
595
  ].join('\n');
587
596
  }
597
+ // ── .gitignore ────────────────────────────────────────────────────────────────
598
+ function gitignore() {
599
+ return [
600
+ `node_modules`,
601
+ `dist`,
602
+ `.env`,
603
+ `*.js.map`,
604
+ ``,
605
+ ].join('\n');
606
+ }
607
+ // ── .env.example ──────────────────────────────────────────────────────────────
608
+ function envExample(a) {
609
+ const defaultPort = a.transport === 'ssh' ? '22' : a.transport === 'https' ? '47700' : '57700';
610
+ return [
611
+ `# IBM i connection — copy to .env and fill in your values`,
612
+ `IBMI_TRANSPORT=${a.transport}`,
613
+ `IBMI_SYSTEM=my-ibmi.example.com`,
614
+ `IBMI_USER=`,
615
+ `IBMI_PASS=`,
616
+ ...(a.transport === 'http' || a.transport === 'https'
617
+ ? [`IBMI_PORT=${defaultPort}`, `IBMI_DATABASE=*LOCAL`]
618
+ : []),
619
+ ...(a.transport === 'ssh' ? [`IBMI_SSH_PORT=${defaultPort}`] : []),
620
+ `PORT=3000`,
621
+ ``,
622
+ ].join('\n');
623
+ }
588
624
  // ── .vscode/settings.json ─────────────────────────────────────────────────────
589
625
  function vscodeSettings() {
590
626
  return JSON.stringify({
@@ -737,7 +773,7 @@ function readme(a, hasProgram, hasTable) {
737
773
  `## Development`,
738
774
  ``,
739
775
  `\`\`\`bash`,
740
- `npm run dev # starts with nodemon — restarts on file save`,
776
+ `npm run dev # nest start --watchrebuilds and restarts on file save`,
741
777
  `\`\`\``,
742
778
  ``,
743
779
  `## 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.2",
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",