@memberjunction/cli 1.1.0 → 1.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ $ npm install -g @memberjunction/cli
12
12
  $ mj COMMAND
13
13
  running command...
14
14
  $ mj (--version)
15
- @memberjunction/cli/1.1.0 linux-x64 node-v20.12.2
15
+ @memberjunction/cli/1.1.2 linux-x64 node-v20.12.2
16
16
  $ mj --help [COMMAND]
17
17
  USAGE
18
18
  $ mj COMMAND
@@ -63,7 +63,7 @@ EXAMPLES
63
63
  $ mj install
64
64
  ```
65
65
 
66
- _See code: [src/commands/install/index.ts](https://github.com/MemberJunction/MJ/blob/v1.1.0/src/commands/install/index.ts)_
66
+ _See code: [src/commands/install/index.ts](https://github.com/MemberJunction/MJ/blob/v1.1.2/src/commands/install/index.ts)_
67
67
 
68
68
  ## `mj version`
69
69
 
@@ -118,6 +118,7 @@ export default class Install extends Command {
118
118
  * @param {...string} dirs - The directories to check.
119
119
  */
120
120
  verifyDirs(...dirs: string[]): void;
121
+ checkNodeVersion(): void;
121
122
  /**
122
123
  * Checks if there is at least `numGB` GB of free disk space.
123
124
  * @param {number} numGB - The number of GB to check for.
@@ -42,10 +42,10 @@ const MJ_BASE_DIR = 'MJ_BASE';
42
42
  const MJAPI_DIR = 'MJAPI';
43
43
  const MJEXPLORER_DIR = 'MJExplorer';
44
44
  const configSchema = zod_1.z.object({
45
- dbUrl: zod_1.z.string().url(),
45
+ dbUrl: zod_1.z.string().min(1),
46
46
  dbInstance: zod_1.z.string(),
47
47
  dbTrustServerCertificate: zod_1.z.enum(['Y', 'N']),
48
- dbDatabase: zod_1.z.string(),
48
+ dbDatabase: zod_1.z.string().min(1),
49
49
  dbPort: zod_1.z.number({ coerce: true }).int().positive(),
50
50
  codeGenLogin: zod_1.z.string(),
51
51
  codeGenPwD: zod_1.z.string(),
@@ -81,6 +81,7 @@ class Install extends core_1.Command {
81
81
  async run() {
82
82
  const parsed = await this.parse(Install);
83
83
  this.flags = parsed.flags;
84
+ this.checkNodeVersion();
84
85
  this.checkAvailableDiskSpace(2);
85
86
  this.verifyDirs(CODEGEN_DIR, GENERATED_ENTITIES_DIR, SQL_SCRIPTS_DIR, MJAPI_DIR, MJEXPLORER_DIR);
86
87
  this.userConfig = await this.getUserConfiguration();
@@ -130,16 +131,14 @@ AI_VENDOR_API_KEY__AnthropicLLM='${this.userConfig.anthropicAPIKey}'
130
131
  CONFIG_FILE='config.json'
131
132
  `;
132
133
  fs.writeFileSync(node_path_1.default.join(CODEGEN_DIR, '.env'), codeGenENV);
133
- this.log(' Running npm install...');
134
- (0, node_child_process_1.execSync)('npm install', { stdio: 'inherit', cwd: CODEGEN_DIR });
135
134
  this.log(' Running npm link for GeneratedEntities...');
136
135
  (0, node_child_process_1.execSync)('npm link ../GeneratedEntities', { stdio: 'inherit', cwd: CODEGEN_DIR });
137
136
  //*******************************************************************
138
137
  // Process MJAPI
139
138
  //*******************************************************************
140
139
  this.log('\n\nBootstrapping MJAPI...');
141
- this.log(' Running npm install...');
142
- (0, node_child_process_1.execSync)('npm install', { stdio: 'inherit', cwd: MJAPI_DIR });
140
+ this.log(' Running npm link for GeneratedEntities...');
141
+ (0, node_child_process_1.execSync)('npm link ../GeneratedEntities', { stdio: 'inherit', cwd: MJAPI_DIR });
143
142
  this.log(' Setting up MJAPI .env file...');
144
143
  const mjAPIENV = `#Database Setup
145
144
  DB_HOST='${this.userConfig.dbUrl}'
@@ -182,13 +181,11 @@ ASK_SKIP_ORGANIZATION_ID = 1
182
181
  CONFIG_FILE='config.json'
183
182
  `;
184
183
  fs.writeFileSync(node_path_1.default.join(MJAPI_DIR, '.env'), mjAPIENV);
185
- this.log(' Running npm link for GeneratedEntities...');
186
- (0, node_child_process_1.execSync)('npm link ../GeneratedEntities', { stdio: 'inherit', cwd: MJAPI_DIR });
187
184
  this.log('Running CodeGen...');
188
185
  this.renameFolderToMJ_BASE(this.userConfig.dbDatabase);
189
186
  // next, run CodeGen
190
187
  // We do not manually run the compilation for GeneratedEntities because CodeGen handles that, but notice above that we did npm install for GeneratedEntities otherwise when CodeGen attempts to compile it, it will fail.
191
- (0, node_child_process_1.execSync)('npx tsx src/index.ts', { stdio: 'inherit', cwd: CODEGEN_DIR });
188
+ (0, node_child_process_1.execSync)('npx ts-node src/index.ts', { stdio: 'inherit', cwd: CODEGEN_DIR });
192
189
  // Process MJExplorer
193
190
  this.log('\nProcessing MJExplorer...');
194
191
  this.log('\n Updating environment files...');
@@ -201,8 +198,6 @@ CONFIG_FILE='config.json'
201
198
  };
202
199
  await this.updateEnvironmentFiles(MJEXPLORER_DIR, config);
203
200
  // keep on going with MJ Explorer - do the rest of the stuff
204
- this.log(' Running npm install...');
205
- (0, node_child_process_1.execSync)('npm install', { stdio: 'inherit', cwd: MJEXPLORER_DIR });
206
201
  this.log(' Running npm link for GeneratedEntities...');
207
202
  (0, node_child_process_1.execSync)('npm link ../GeneratedEntities', { stdio: 'inherit', cwd: MJEXPLORER_DIR });
208
203
  this.log('Installation complete!');
@@ -226,7 +221,10 @@ CONFIG_FILE='config.json'
226
221
  }
227
222
  if (!userConfig) {
228
223
  this.log('\n>>> Please answer the following questions to setup the .env files for CodeGen. After this process you can manually edit the .env file in CodeGen as desired.');
229
- const dbUrl = await (0, prompts_1.input)({ message: 'Enter the database server URL:' });
224
+ const dbUrl = await (0, prompts_1.input)({
225
+ message: 'Enter the database server hostname:',
226
+ validate: (v) => configSchema.shape.dbDatabase.safeParse(v).success,
227
+ });
230
228
  const dbInstance = await (0, prompts_1.input)({
231
229
  message: 'If you are using a named instance on that server, if so, enter the name here, if not leave blank:',
232
230
  });
@@ -235,7 +233,10 @@ CONFIG_FILE='config.json'
235
233
  }))
236
234
  ? 'Y'
237
235
  : 'N';
238
- const dbDatabase = await (0, prompts_1.input)({ message: 'Enter the database name on that server:' });
236
+ const dbDatabase = await (0, prompts_1.input)({
237
+ message: 'Enter the database name on that server:',
238
+ validate: (v) => configSchema.shape.dbDatabase.safeParse(v).success,
239
+ });
239
240
  const dbPort = await (0, prompts_1.input)({
240
241
  message: 'Enter the port the database server listens on',
241
242
  validate: (v) => configSchema.shape.dbPort.safeParse(v).success,
@@ -322,6 +323,12 @@ CONFIG_FILE='config.json'
322
323
  }
323
324
  });
324
325
  }
326
+ checkNodeVersion() {
327
+ const validNodeVersion = Number(process.version.replace(/^v(\d+).*/, '$1')) >= 20;
328
+ if (!validNodeVersion) {
329
+ this.error('MemberJunction requires Node.js version 20 or higher.', { exit: 1 });
330
+ }
331
+ }
325
332
  /**
326
333
  * Checks if there is at least `numGB` GB of free disk space.
327
334
  * @param {number} numGB - The number of GB to check for.
@@ -397,6 +404,10 @@ CONFIG_FILE='config.json'
397
404
  // rename the MJ_BASE set of SQL Scripts to our new dbname
398
405
  const oldFolderPath = node_path_1.default.join(SQL_SCRIPTS_DIR, GENERATED_DIR, MJ_BASE_DIR);
399
406
  const newFolderPath = node_path_1.default.join(SQL_SCRIPTS_DIR, GENERATED_DIR, dbDatabase); // Assuming dbDatabase holds the new name
407
+ if (!fs.existsSync(oldFolderPath)) {
408
+ this.warn(`SQL scripts not found at '${oldFolderPath}', skipping rename`);
409
+ return;
410
+ }
400
411
  try {
401
412
  fs.moveSync(oldFolderPath, newFolderPath);
402
413
  this.log(`Renamed ${oldFolderPath} to ${newFolderPath} successfully.`);
@@ -33,5 +33,5 @@
33
33
  ]
34
34
  }
35
35
  },
36
- "version": "1.1.0"
36
+ "version": "1.1.2"
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "MemberJunction command line tools",
5
5
  "keywords": [
6
6
  "oclif"